- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hey,
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
Did you look through the WordPress support forms? It looks like you need a foreach statement. This seems similar to your problem:
http://wordpress.org/support/topic/282336
"; print_r($cf1values); echo "
“;
if ($cf1values) {
foreach ($cf1values as $cf1value) {
echo ‘
for post id: ‘.$post->ID.’ cf1 value is: ‘.$cf1value .’
‘;
}
}
?>
Magic ‘downstairsdev’
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:
"; print_r($featured); echo "
“;
if ($featured) {
foreach ($featured as $image) {
echo ““;
}
}
?>