How To Get Value Of A Specific Custom Field In WordPress

WordPress allows us to add some extra metadata to our posts with the help of custom fields. You can do a lot of amazing work with these custom fields, as well as most of theme developers use these fields in their amazing themes. Adding a custom field to your post is really easy. Just add the field name and content from your post editor and that’s it.

Now, here’s the most confusing part for the newbies. How to get the value of a specific custom field and display it in your post? The following snippet will show values of all the custom fields of the post:

Here’s how you can get value of a specific custom field in your post:

The above code will get the value of “video” field. And here’s how to display custom field only if they exists:

Leave a Reply