WordPress allows us to add custom fields to a our posts, which adds extra information, which is known as meta-data. But we can do a lot more there custom fields. For example, I embedded a video in this post with the use of custom fields.
More of newbies gets confused when it comes to use custom fields. But they're not that complicated, at least the basic use of these fields.
Here's how you can get value of a specific custom field in your WordPress posts:
"mood" would be ID value of custom field. That was simple.
And here's how to display custom field only if exists:
More of newbies gets confused when it comes to use custom fields. But they're not that complicated, at least the basic use of these fields.
Here's how you can get value of a specific custom field in your WordPress posts:
<?php echo get_post_meta($post->ID, 'mood', true); ?>
"mood" would be ID value of custom field. That was simple.
And here's how to display custom field only if exists:
<?php
$url = get_post_meta($post->ID, 'snippet-reference-URL', true);
if ($url) {
echo "<p><a href='$url'>Reference URL</a></p>";
}
?>