Hey, Thanks for your code.
I tried it out but I can't get it to work entirely.
FYI : I have a comma separated list of ids in my "Product" field (i.e. "1, 56, 98, 203").
- If I test the $single_posts variable it lists the post ids as it should.
- If I test the $post_array variable it outputs "array" instead of the values of the array.
Here are my findings so far. Do you have any ideas?
Here's the non working version
<?php $products = get_post_meta($post->ID, 'products', true);
if($products != '') {
$single_posts = get_post_meta($post->ID, 'products', true);
$post_array = array($single_posts); //construct array for single posts id's
$args = array(
'order' => 'desc',
'p' => $post_array
);
$single_post_fields = new WP_Query($args);
$count = 0; ?>
<div class="categoryimages">
<?php echo $args ?>
<ul>
<?php while ($single_post_fields->have_posts()) : $single_post_fields->the_post(); $do_not_duplicate = $post->ID; ?>
<li><?php the_post_thumbnail('thumbnail'); ?></li>
<?php endwhile; wp_reset_query(); ?>
</ul>
</div>
<?php } ?>
This version displays the first post in the list of ids (better, but I need it to display all of them)
<?php $products = get_post_meta($post->ID, 'products', true);
if($products != '') {
$single_posts = get_post_meta($post->ID, 'products', true);
$post_array = array($single_posts); //construct array for single posts id's
$args = array(
'order' => 'desc',
'p' => $single_posts
);
$single_post_fields = new WP_Query($args);
$count = 0; ?>
<div class="categoryimages">
<?php echo $args ?>
<ul>
<?php while ($single_post_fields->have_posts()) : $single_post_fields->the_post(); $do_not_duplicate = $post->ID; ?>
<li><?php the_post_thumbnail('thumbnail'); ?></li>
<?php endwhile; wp_reset_query(); ?>
</ul>
</div>
<?php } ?>