Skip to content

Instantly share code, notes, and snippets.

@jeffreysbrother
Last active January 26, 2017 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreysbrother/9f1c32fdbc0042857df464662db5b9a2 to your computer and use it in GitHub Desktop.
Save jeffreysbrother/9f1c32fdbc0042857df464662db5b9a2 to your computer and use it in GitHub Desktop.
//activate custom fields in wordpress and name that field. Replace 'about_blurb' below with the selected name (I don't think hyphens can be used here)
<?php $meta_value = get_post_meta($post->ID, 'about_blurb', true);
if (!empty($meta_value)) {
echo '<p>' . $meta_value . '</p>';
} ?>
//however, we can use the Advanced Custom Fields plugin for something much better
//this goes in our template file:
<p><?php the_field( 'about_blurb' ); ?></p>
//then, in the plugin settings, we can create custom fields that will appear on certain pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment