January 16, 2015

Show custom field information in your posts by name

Here is a simple documentation on how to show your custom field data or post meta data by name. Instead of relying on the stupid “get_post_meta” function that gives you an unordered list.

It looks like this:

[pastacode lang=”php” message=”Usage from WordPress.org” highlight=”” provider=”manual”]

<?php $meta_values = get_post_meta( $post_id, $key, $single ); ?>

[/pastacode]

 

Here’s how to use it practically:

[pastacode lang=”php” message=”Simple get post meta by name” highlight=”” provider=”manual”]

<?php $custom_field = get_post_meta($post->ID, 'your_fieldname_here', true); ?>
<?php echo $custom_field ?>

[/pastacode]