Here i will show you how to enable, create and get value of WordPress custom fields.
WordPress custom fields, also referred to as post meta, is a feature in WordPress which allows users to add additional information when writing a post or add a page. WordPress keep or store this information as meta data. Users can easily display this meta data by using get_post_meta() function.
Do you know WordPress custom fields are hidden by default. If you want to make the custom fields visible on your post edit screen, then you need to click on Screen Options button on the top right corner of your admin screen. In the menu, simply check “Custom Fields” checkbox.
After make visible custom field scroll down to edit post page below editor custom filed tab is there, inside tab below add custom field button one small blue color text visible “enter new” click non that give name and value press add custom filed button.
You can easily display this meta data by using get_post_meta() function.
Here i am create custom field with the name of “subheading”.
<?php $subheading = get_post_meta( get_the_ID(), 'subheading', true ); if(!empty($subheading) && $subheading!="") { echo '<h2>'.$subheading.'</h2>'; } ?>
Tags: WordPress custom fields tutorial, how to use WordPress custom fields, WordPress custom fields not showing, WordPress custom fields, how to add custom field in custom post type in WordPress , WordPress create custom field programmatically, WordPress display custom field, how to get custom field value in WordPress , how to display custom field WordPress
My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.