Problem with using ‘category__in’ in query_posts and ‘category’ in get_posts as passing arguments

i am trying this with query_posts :

$post_category = 12,9
$post_category_array = explode(',', $post_category); 
query_posts( 
      array( 
           'post_type'      => $post_type,
           'orderby'        => 'menu_order',
           'order'          => 'ASC',
           'posts_per_page' => $limit,
           'category__in'   => $post_category_array
           )
      );

But my query print this :

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND 0 = 1 AND wp_posts.post_type = 'arka_team' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10

and this will not get any row, because in query there is a condition like 0 = 1.

I have also tried this :

              $args = array(
                        'posts_per_page'   => $limit,
                        'category'         => $post_category,
                        'orderby'          => 'menu_order',
                        'order'            => 'ASC',
                        'post_type'        => $post_type,
                        'post_status'      => 'publish',
                        'suppress_filters' => true );

             $postslist = get_posts( $args );


             foreach ( $postslist as $post ) :
                  setup_postdata( $post ); ?> 
                    <div>
                        <?php the_date(); ?>

                        <?php the_title(); ?>   
                        <?php the_excerpt(); ?>
                    </div>
                <?php
                endforeach; 
                wp_reset_postdata();

But this also print same query with condition 0 = 1 .
Please help me.

Read more here: Problem with using ‘category__in’ in query_posts and ‘category’ in get_posts as passing arguments

Leave a Reply

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