World Food Day sale

Limited-time deal: Up to 70% off Hurry before it ends!
Save Now

Days

Hrs

Min

Sec

Product successfully added to your shopping cart.

View Categories

WordPress – What are custom fields in WordPress

Table of Contents

Custom fields are a somewhat more advanced WordPress feature that lets you add extra information to specific posts. That information is called ‘metadata’. Custom fields and metadata are of particular use to developers, who can use them to extend posts with all sorts of additional coding.

Add Custom Fields to Your WordPress Posts

1: Enable Custom Fields and Assign New Metadata to Your Post

Click on the three dots in the top right corner and select Preferences from the dropdown list:

WordPress - What are custom fields in WordPress - TemplateTrip

Then, select Panels from the popup menu and enable Custom fields. You’ll now be prompted to Enable & Reload:

WordPress - What are custom fields in WordPress - TemplateTrip

Now, if you scroll down below the post, you’ll find a new section:

WordPress - What are custom fields in WordPress - TemplateTrip

2: Add Conditional Code to Your Theme File

Within WordPress, you’ll want to navigate to Tools > Theme File Editor. Here, you can look through and make changes to the files that make up your site. You’ll want to check out the sidebar on the right-hand side and find the Single Post file (also known as single.php):

 
$meta = get_post_meta( get_the_ID(), 'Sponsored Post' ); 
if( $meta[0] == 'Yes' ) { 
     This post is sponsored content, and we received a free copy of the product in order to conduct our review.
}

Latest WordPress Products #