• I got a query made to loop for specific post ids (below).

    But when I run the loop it just displays the most recent posts.

    What can I do to fix this?

    <?php
    $post_id = array(483,486);
     $posts = get_posts( $post_id);
     foreach( $posts as $post ) :
      setup_postdata($post);  ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

    example:

    $posts = get_posts( array( 'post__in' => $post_id ) );
    Thread Starter blogthisnow

    (@blogthisnow)

    What? Maybe a good answer but not very clear on what exactly you’ve instructed ,me to do with my code above?

    Thread Starter blogthisnow

    (@blogthisnow)

    That doesn’t work either.

    <?php
    $post_id = array(483,486);
     $posts = get_posts( array( 'post_type' => 'post', 'post__in' => $post_id ) );
     foreach( $posts as $post ) :
      setup_postdata($post);  ?>	
    
        <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    
    						 <a class="thumb" href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '" class="hthumb"'); ?></a><?php the_excerpt(45); ?><a href="<?php the_permalink(); ?>" class="more">Read More..</a><div style="clear:both;"></div>
    <?php endforeach; ?>

    what is the output, if any?

    any error messages?

    do posts 483 and 486 really exist?

    where exactly are you integrating the code?

    can you post a link to your site to illustrate the output?

    what happens is if you temporarily deactivate all plugins?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post loop for specific post ids?’ is closed to new replies.