• Hi, folks!

    I used page_options to define my frontpage posts, and use this code to get que posts for a slide

    $slide_home = get_option('posts_home-slide'); // this retuns a string like this "481,1,922'
    $include = explode(',',$slide_home);
    $argsSlide = array(
    	'post_type'=>'any',
    	'post_status'=>'publish',
    	'posts_per_page'=>'-1',
    	'post__in'=>$include
    	);
    $slide = new WP_Query($argsSlide);
      if ($slide->have_posts()):
        while($slide->have_posts()):
            $slide->the_post();
        endwhile;
       endif;
    wp_reset_query();
    wp_reset_postdata();

    But this query did not return the 3 posts I pass in post__in and return more than three. Someone could help me?

Viewing 4 replies - 1 through 4 (of 4 total)
  • What do you get when you do a print_r on the $include array? Do you only get the three ID’s that you’re expecting?

    Thread Starter cataua

    (@cataua)

    The $include give me a array with the Ids, like this
    Array ( [0] => 418 [1] => 1 [2] => 922 ), and yes the $include array give only the three Id’s there I get from the DB.

    Have you tried removing all arguments except ‘post__in’? I’m thinking that your ‘posts_per_page’=>’-1′ is the problem, but I’d try removing ‘post_type’ too. I’d probably leave ‘post_status’ to make it easier to manage your posts.

    Thread Starter cataua

    (@cataua)

    Yes, I already did this and give the same return :/ Funny I made a short code for the next sections and works well the post__in and WP_Query….. :/

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP_Query and post__in’ is closed to new replies.