How to Create and get WordPress Custom Field

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.

How to enable WordPress custom fields

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.

How to Enable WordPress Custom Field

How to create new WordPress custom field

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.

How to Get WordPress Custom Field

How to get value of WordPress custom field

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts: You may like

How to Add Post Thumbnail to RSS Feed in WordPress

How to track contact form 7 form in salesforce without plugin

Contact Form 7 Redirect to Thank You Page

How to Validation Business Email in Contact Form 7 WordPress

How to add post from frontend in wordpress without plugin

WordPress Websites Are SEO Friendly Or Not

How to get last insert id in WordPress

How to Change WordPress Email From Sender Name Email Settings Without Plugin

How to Create Custom Shortcodes in WordPress

how to fetch custom post by tags in WordPress

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Free online tool to download Instagram videos, photos and save Instagram videos, photos to your device. It's free & easy to use.

Download Now

CURRENCY CONVERTER

Our real time currency converter calculator will convert your money based on current values from around the world. It's free & easy to use.

Convert Now

ROBOST.TXT GEN.

Create robots txt file that help search engines to crawling and indexing your site with help of our free online Robots.txt Generator tool.

Create Now

HTML MINIFIER

Free online tool to minify or compress html code and reduce the size of html code in few clicks. It's free & easy to use.

Minify Now

CSS MINIFIER

Free online tool to minify or compress css code and reduce the size of css code in few clicks. It's free & easy to use.

Minify Now

JAVASCRIPT MINIFIER

Free online tool to minify or compress javascript code and reduce the size of javascript code in few clicks. It's free & easy to use.

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.