您需要使用WP Query 搜索该类别的帖子。
它将类似于:
$author = get_the_author(); // defines your author ID if it is on the post in question
$args = array(
\'post_type\' => \'book\',
\'post_status\' => \'publish\',
\'author\'=>$author,
\'posts_per_page\' => 5, // the number of posts (books) you\'d like to show
\'orderby\' => \'date\',
\'order\' => \'DESC\'
);
$results = new WP_Query($args);
// \'<pre>\'.print_r($results).\'</pre>\'; // This is a useful line to keep - uncomment it to print all results found - it can then be used to work out if the query is doing the right thing or not.
while ($results->have_posts()) {
$results->the_post();
the_title();
echo \'</hr>\'; // puts a horizontal line between results if necessary
}
wp_reset_postdata(); //re-sets everything back to normal
}