Skip to content

Instantly share code, notes, and snippets.

@mrtwebdesign
Created July 22, 2012 12:39
Show Gist options
  • Select an option

  • Save mrtwebdesign/3159537 to your computer and use it in GitHub Desktop.

Select an option

Save mrtwebdesign/3159537 to your computer and use it in GitHub Desktop.
WP output key value pair of custom field
<?php if ( get_post_meta($post->ID, '$key', true) ) : ?>
<div id="key" class="class">
<div class="key-label">Label:</div>
<div class="key-value">
<?php echo get_post_meta($post->ID, 'CustomFieldLabel', true); ?>
</div>
</div>
<?php endif; ?>
@mrtwebdesign
Copy link
Author

Output the key/value pair of a custom field of a page or post if that pair exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment