wordpress wp_query with redux option is not working

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:

Read More
<?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.

Related posts

Leave a Reply

2 comments

  1. Try:

    global $redux_imd;
    
    $featured_rcp = !empty($redux_imd['featured_rcp']) ? $redux_imd['featured_rcp'] : array();
    
    if ( !empty($featured_rcp) ) :
    
        query_posts( array( 'cat' => $featured_rcp, 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'DESC' ) );
    
        if (have_posts()) : 
             while (have_posts()) : the_post();
                 the_title()
             endwhile;
        else :
            _e('No post found!');
        endif; 
    
    endif;
    

    Working for me.