0

I am going to put multiple value on custom field using same key (my key is link). So the value will be value A and value B

And heres my custom field code for single value:

<a href="<?php $key="link"; echo get_post_meta($post->ID, $key, true); ?>" target="_blank">Images Source</a>

So the question is ,how to display multiple value one? as you can see I have my code for single value already above.

1 Answer 1

3
<?php
// get an array of multiple values
$post_meta_array = get_post_meta($post->ID, 'link'); // do not use 'true' as the third argument
// echo the link for each value 
foreach ($post_meta_array as $post_meta) {
    echo '<a href="' . $post_meta . '" target="_blank">Images Source</a>';
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.