Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Help please custom fields

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #25604
    benn
    Participant

    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.

    Code:

      ID, ‘featured’, $single);
      ?>

      “;
      ?>

    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

    #61513

    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

    Code:
    ID, ‘cf1’, false);
    echo “

    "; print_r($cf1values); echo "

    “;
    if ($cf1values) {
    foreach ($cf1values as $cf1value) {
    echo ‘

    for post id: ‘.$post->ID.’ cf1 value is: ‘.$cf1value .’

    ‘;
    }
    }
    ?>

    #61515
    benn
    Participant

    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:

    Code:
    ID, ‘featured’, false);
    //echo “

    "; print_r($featured); echo "

    “;
    if ($featured) {
    foreach ($featured as $image) {
    echo ““;
    }
    }
    ?>

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.