I am trying to display posts of specific category(taxonomy) that is 'Book1'.
I tried to display it with the following code.
$args = array(
'post_type' => 'book',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'Book1',
'field' => 'id',
'terms' => 1
)
)
);
echo '<br>';
$postss = get_posts( $args );
if ( ! empty( $postss ) && is_array( $postss ) ) {
// Run a loop and print them all
$i=1;
foreach ( $postss as $termm ) {
echo ' '.$i.' '.$termm->post_title. '<br>';
$i++;
}
}
?>
In output no any item is displayed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…