Category name in query should dynamically come

<?php wp_dropdown_categories(); ?>

→ This is how we can populate the categories in a drop-down.

<?php
// the query
$the_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘posts_per_page’ => 10,
‘post_status’ => ‘publish’,
‘category_name’ => ‘staff’
) );
?>

I need some help in php here →

‘category_name’ => ‘staff’

staff is a category here. How can we write in terms of PHP so that whatever category is chosen from the populated category from the drop-down should come above dynamically based on the selection from the drop-down?

Read more here:: Category name in query should dynamically come

Leave a Reply

Your email address will not be published. Required fields are marked *