カスタム作成者ページを持つサイトで作業しており、作成者ページには、その作成者による他の投稿を表示する最近の作成者投稿ウィジェットがあります。このサイトには複数の作成者がいるため、投稿ごとに異なり、これを行うプラグインは見つかりませんでした. 投稿のサムネイル、タイトル、カテゴリ名を表示しようとしています。
タイトルとサムネイルを表示している関数を使用していますが、カテゴリがありません。カテゴリを追加しようとしました: the_category(' ','multiple',$authors_post->ID) 残念ながら、最初の li にすべてのカテゴリが表示されます。各投稿の代わりに。
これが私が取り組んでいるものです:
function get_related_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID,
'post__not_in' => array( $post->ID ), 'posts_per_page' => 3 ) );
$output = '<ul>';
foreach ( $authors_posts as $authors_post ) {
$output .= '<li>' . get_the_post_thumbnail( $authors_post->ID, 'xsmall-thumb' )
. '<p>' . the_category(' ','multiple',$authors_post->ID)
. '</p> <a href="' . get_permalink( $authors_post->ID )
. '">' . apply_filters( 'the_title', $authors_post->post_title,
$authors_post->ID ) . '</a></li>';
}
$output .= '</ul>';
return $output;
}
どんな助けでも大歓迎です、ありがとう!