質問
著者の名前と説明のみを表示することは可能ですか(別名バイオ) もしも 説明にはテキストが含まれていますか?
このコードは機能しません(名前や説明は返されません)が、この目標を達成するために編集できることを願っています。
<?php
$authorDesc = the_author_meta($post->ID, 'description', true);
if (!empty($authorDesc)) {
?>
<em>by <?php the_author(); ?></em>
<span><?php the_author_meta('description'); ?></span>
<?php } ?>
解決
<?php
$authordesc = get_the_author_meta( 'description' );
if ( ! empty ( $authordesc ) )
{
?>
<a href="<?php
echo get_author_posts_url( get_the_author_meta( 'id' ) );
?>"><?php
the_author();
?></a>
<?php
echo wpautop( $authordesc );
}
他のヒント
まず、使用する必要があります get_the_author_meta
それ以外の the_autho_meta
バキューを与える $authorDesc
(get_the_author_meta
値を返し、 the_author_meta
表示します)。
第二に、使用する必要があります user_description
両方の機能の代わりに機能するように description
.
それがうまくいくことを願っています。
編集 - ここ のドキュメントです the_author_meta
詳細については。編集2-また、最初のパラメーターとして$ post> idを宣言する必要はありません the_author_meta
. 。ループ内で使用していますか?
所属していません wordpress.stackexchange