We have created various categories using WordPress CMS. We have to filter the data by clicking categories. I need to filter the category values (data) when I click more than two category. I have used array_intersect
concepts for picking common values among categories. But It's working for two categories alone.
When I click (which is a select option) more than two categories, it didn't work. Please help me to find the solution.
Try this, it should work (but untested for now):
<?php
$args = array(
'post_type' => 'post',
'cat' => '33,45,56'
)
$query = new WP_Query( $args );
if( $query->have_posts() ) {
while( $query->have_posts() ): $query->the_post();
/* do stuff here */
endwhile;
wp_reset_postdata();
}
?>
Check the WP Query Codex (Category Parameters) for more information