Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to use WordPress custom fields

Custom fields let you add extra details to a post, like a price or a book author. This guide shows how to add and show them.

WordPress2 min read15 steps2 screenshots

What are custom fields?

Every post has a title and a body. A custom field is an extra labeled piece of information. It has a name (the key) and a value. For example, the name could be mood and the value could be happy. Think of a sticky note attached to your post.

Screenshot: Every post has a title and a body. A custom field is an extra labeled piece of information

WordPress calls this data "post meta". It is stored in your database, which is where WordPress keeps all its content.

Step 1: Turn on the Custom Fields box

  1. Log in to your WordPress dashboard.
  2. Open a post or page in the editor.
  3. Click the three dots in the top right corner.
  4. Click Preferences.
  5. Open the Panels section.
  6. Switch on Custom Fields.
  7. The page reloads. Scroll to the bottom of the editor to see the new box.

Step 2: Add a custom field

  1. In the Custom Fields box, click Enter new.
    Screenshot: In the Custom Fields box, click Enter new .
  2. Type a name in the Name box, such as book_author.
  3. Type the value in the Value box, such as Jane Smith.
  4. Click Add Custom Field.
  5. Click Update to save the post.

Next time, you can pick the same name from a list and add a new value.

Step 3: Show the field on your page

Adding a field does not show it to visitors by itself. You need a little code in your theme. A child theme is the safest place, because it keeps changes when the main theme updates. Take a backup first.

<?php
$author = get_post_meta( get_the_ID(), 'book_author', true );
if ( $author ) {
    echo '<p>Author: ' . esc_html( $author ) . '</p>';
}
?>

This reads the book_author value for the current post and prints it. The esc_html part makes the text safe to show. Place this code in a template file such as single.php, inside the post loop.

Edit or delete a field

  1. Open the post.
  2. Find the field in the Custom Fields box.
  3. Change the value and click Update, or click Delete to remove it.

Use a plugin instead

A plugin is an add-on for WordPress. Plugins like Advanced Custom Fields give you friendly boxes, so you do not need to type names by hand. They also help with showing fields without code.

Tip: Use lowercase names with underscores and no spaces. This avoids mistakes.

Quick recap

  • A custom field is a name and value attached to a post.
  • Turn on the box under Preferences, then Panels.
  • Use get_post_meta to show a field.
  • A plugin can make this easier.