WordPress: Using custom field to define posts to display in loop

Posted by j-man86 on Stack Overflow See other posts from Stack Overflow or by j-man86
Published on 2010-05-28T16:17:51Z Indexed on 2010/05/28 16:22 UTC
Read the original article Hit count: 301

Filed under:
|
|

Hi,

I'm trying to use a custom field in which I input the post ID numbers of the posts I want to show, seperated by commas. For some reason though, only the first post of the series of the post IDs are displaying. Can someone help? The value of $nlPostIds is (minus the quotes): "1542,1534,1546". Here's the code... the most important part is the 4th line 'post__in' => array($nlPostIds)

<?php 
$nlPostIds = get_post_meta($post->ID, 'nlPostIds', true);
$args=array(
    'post__in' => array($nlPostIds)
   );
query_posts($args);
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

<div class="entry">
            <div class="post" id="post-<?php the_ID(); ?>">
                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="allinfos"><span class="date"><?php the_time('F jS, Y') ?></span> | <span class="comments"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> </span> | <span class="category">Posted in <?php the_category(', ') ?></span> <!-- by <?php the_author() ?> --></div>

                    <?php the_content('More &raquo;'); ?>

<?php the_tags('Tags: ', ', ', ' '); ?> <?php edit_post_link('Edit', '[ ', ' ]'); ?>
<div class="clear"></div>
</div></div>
<?php endwhile; endif; ?>

Thanks!

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about loop