Support » How-To and Troubleshooting » WP_Query and post__in

WP_Query and post__in

  • 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(
    $slide = new WP_Query($argsSlide);
      if ($slide->have_posts()):

    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?

    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.

    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.