Forums

Return multiple custom fields of same key for same post? (3 posts)

  1. isermesh
    Member
    Posted 6 years ago #

    Is it possible to return multiple custom fields that have the same key (from the same post) within the Loop?
    I've tried Coffee2Code's plugin, but it doesn't seem to have this ability. Am I incorrect, or is there another way of doing this?
    Many thanks.

  2. Kafkaesqui
    Moderator
    Posted 6 years ago #

    Simplest way is to add this to your template (in The Loop:

    <?php foreach(get_post_custom_values('key') as $value) : ?>

    ~ This displays on each occurence of the custom field key 'key' -- to output the value: <?php echo $value; ?>

    <?php endforeach; ?>

  3. isermesh
    Member
    Posted 6 years ago #

    Thanks! This works splendidly.

Topic Closed

This topic has been closed to new replies.

About this Topic