How to display multiple custom field values

Adding this snippet within the loop of your wordpress theme will let you display multiple instances of a custom field value.

 

 

 

<?php
$press_quotes = get_post_meta($post->ID, "pressquote", false);
if ($press_quotes[0]=="") { ?>
<!-- If there are no custom fields, show nothing -->
<?php } else { ?>
<div>
<h3>From the Press</h3>
<?php foreach($press_quotes as $press_quotes) {
echo '<blockquote><p>'.$press_quotes.'</p></blockquote>';
} ?>
</div>
<?php } ?>

Be Sociable, Share!

Leave a comment