I want to have the ability to choose a category from theme option panel & it ll show all the posts from that exact particular category.
so I have setup my wp_query like this:
<?php
$featured_rcp= $redux_imd['featured_rcp'];
$catquery = new WP_Query(array(
'category' => $featured_rcp,
'posts_per_page' => 1
));
while($catquery->have_posts()) : $catquery->the_post();
?>
& my theme option panel code is:
'id' => 'featured_rcp',
'type' => 'select',
'data' => 'categories',
'multi' => true,
'title' => __('Recipe Category.', 'imd'),
'subtitle' => __('Recipe Category for home page.', 'imd')
but it showing posts from all categories, not the one which I select from option panel. though posts per page is working fine. I’m not well versed in PHP, so please some one tell me where I’m doing wrong here.
The category parameter of the WP_Query is wrong, it should be
cat
orcategory_name
, depending on the type of the value.Check out the Category Parameters of WP_Query and choose which one you need.
Try:
Working for me.