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:

<?php $meta_values = get_post_meta( $post_id, $key, $single ); ?>
Usage from WordPress.org

 

Here’s how to use it practically:

<?php $custom_field = get_post_meta($post->ID, 'your_fieldname_here', true); ?>
<?php echo $custom_field ?>
Simple get post meta by name