<div id=\"main-content\"> <ul id=\"portfolio\"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $featured = get_post_meta($post->ID, 'featured', $single); ?> <?php echo \"<li><img src='$featured' alt='' /></li>\"; ?> <?php endwhile; endif; ?> </ul><!-- end of portfolio --> </div><!-- end main-content -->
<?php$cf1values = get_post_meta($post->ID, 'cf1', false);echo \"<pre>\"; print_r($cf1values); echo \"</pre>\";if ($cf1values) {foreach ($cf1values as $cf1value) {echo '<p>for post id: '.$post->ID.' cf1 value is: '.$cf1value .'</p>';}}?>
<?php $featured = get_post_meta($post->ID, 'featured', false); //echo \"<pre>\"; print_r($featured); echo \"</pre>\"; if ($featured) { foreach ($featured as $image) { echo \"<img src='$image' alt='' />\"; } } ?>
Im really stumped on some custom field generation.
I am trying to call a custom field 'featured' which has a url link to an image path.
In the particular page this code is referencing i have more than one image, but uses the same key id 'featured'.
My issue is that the echo is not looping through and only pulling out the first image.
Can anyone lend a hand so that i can pull all my images out one after the other.
Thanks
B
http://wordpress.org/support/topic/282336
using the foreach statement i was able to echo out all the custom fields with the name 'featured'.
Here is the code that got it working: