I use these codes to print custom field query.
My custom field key is out_wiki
<?php if( get_post_meta($post->ID, "out_wiki", true) ): ?>
<div class="outlink">
<a href="http://en.wikipedia.org/w/index.php?search=<?php echo get_post_meta($post->ID, "out_wiki", true); ?>" target="_blank">
<img src="http://www.wikipedia.com/favicon.ico" title="Wikipedia title">
</a>
</div>
<?php endif; ?>
I want to store multiple values in same custom field key and print them at once. How can I do that?
If you want to store it as site option, you can use
update_option()
:http://codex.wordpress.org/Function_Reference/update_option
Example 1:
If you want to store it as post meta (i.e. for each post), you can use
update_post_meta()
http://codex.wordpress.org/Function_Reference/update_post_meta
Example 2:
Example 3:
If you want to add the custom fields (same meta key) and values from the backend like this:
you can retreieve the values like this: