how to display books of selected category in the sidebar in WordPress without any plugin.
I want to display books in sidebar(Web Page) whose category is activated from the widget(Admin) through checkbox or something like that.
how to display books of selected category in the sidebar in WordPress without any plugin.
I want to display books in sidebar(Web Page) whose category is activated from the widget(Admin) through checkbox or something like that.
$query = new WP_Query( array(
'post_type' => 'book', // name of post type.
'tax_query' => array(
array(
'taxonomy' => 'Book1', // taxonomy name
'field' => 'term_id', // term_id, slug or name
'terms' => 1, // term id, term slug or term name
)
)
) );
while ( $query->have_posts() ) : $query->the_post();
// do stuff here....
endwhile;
/**
* reset the orignal query
* we should use this to reset wp_query
*/
wp_reset_query();