Programming

How to Show Custom Fields in WordPress Without Editing Templates (ACF/SCF Guide)

When building a site with WordPress, you often encounter situations where you want to add custom information like "Price" or "Event Date" to your posts.

This is where custom fields come in handy. However, many people struggle with the template file editing required to display them and end up giving up.

So in this article, we’ll show you how to display custom fields in posts without editing template files!

What Are Custom Fields?

By default, WordPress posts include only basic fields like Title, Content, and Category.
But if you want to add custom items per post—such as Price, Venue, or Date—you can use custom fields to do that.

ACF vs SCF: What’s the Difference?

ACF (Advanced Custom Fields)

One of the most popular custom field management plugins for WordPress. It offers rich features and a user-friendly UI.

SCF (Secure Custom Fields)

A plugin that is compatible with ACF and derived from it.
It was created due to differences in direction between WP Engine (which manages ACF) and WordPress core developers.
Since SCF is based on ACF, there are no major differences at the moment—but that may change in the future.

Let's Install SCF

In this guide, we’ll use the SCF plugin for a hands-on example (there weren’t many tutorials using SCF, so we chose it!).

  1. Go to WordPress Admin > Plugins > Add New
  2. Search for “SCF” or “Secure Custom Fields”
  3. Install and activate the Secure Custom Fields plugin

Note: You can also use Advanced Custom Fields, but we haven't tested this method with it, so it may not work.

Create a Field Group

  1. In the admin menu, click on the new SCF item
  2. Go to Field Groups > Add New

  1. Name the group something like “Test”
  2. Add a text field (set the field name to text)
  3. Click Save Changes

Add a Shortcode to Display It

Next, add the following code to your functions.php file.
This allows you to display the custom field content via a shortcode.

add_shortcode('scf', function ($atts) {
$atts = shortcode_atts([
'field' => '',
'post_id' => get_the_ID(),
], $atts, 'scf');

if (!$atts['field']) return '';

$field = $atts['field'];

$output = '';
if ($field == 'text') {
$data = get_field($atts['field'], $atts['post_id']);
$output .= '<p>' . esc_html($data) . '</p>';
}
return $output;
});

If your theme does not support the Theme File Editor, you’ll need to edit functions.php directly via FTP.

Try Displaying It in a Post

  1. Open the post editor
  2. Enter a value like “Test” into the text field you created with SCF, and save
  3. Add the following shortcode in the post body:
    [scf field="text"]
  1. When you view the post, the word “Test” will be shown inside a <p> tag!

Summary: It Works Even Without Template Files!

We’ve shown how you can display custom fields using shortcodes, without having to touch template files.

This method is especially useful when:

  • You’re working on a small-scale site
  • You only need custom fields in specific posts
  • You prefer not to edit theme files

However, if your site grows or you prioritize maintainability, consider properly editing template files for a more scalable solution.

Sponsored Link

  • Author
プロフィール画像

kaz

Full-stack Engineer specializing in Backend/Frontend/Cloud Infrastructure | Digital Nomad since June 2023, traveling the world | Sharing programming tips and insights | Posting travel updates on X

-Programming
-