我最终改用wp\\u query,因为无论我怎么做,我都无法让wp\\u get\\u recent\\u posts工作。对于将来需要此功能的任何人,以下是我使用的代码:
// Get the ID of the current posts\'s term
$terms = get_the_terms( $post->ID, \'comic-series\' );
// Only get the parent term and ignore child terms
foreach ( $terms as $term ){
if ( $term->parent == 0 ) {
// Query Options
$query_options = array(
\'posts_per_page\' => 1,
\'orderby\' => \'title\', // I\'ve ordered all my posts by title but change this for your needs
\'order\' => \'DESC\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'comic-series\',
\'field\' => \'term_id\',
\'terms\' => $term->term_id,
),
),
);
//Query
$the_query = new WP_Query( $query_options );
while ($the_query -> have_posts()) : $the_query -> the_post();
// Link to the latest page
?> <a href="<?php the_permalink(); ?>">LINK TEXT</a> <?php
endwhile;
wp_reset_postdata();
}
}