To create an SCF (shortcode custom field) in WordPress using a plugin, install the Advanced Custom Fields (ACF) plugin.
Create a new field group and add your desired custom field (like text or WYSIWYG).
Assign the field group to posts, pages, or custom post types.
Add content to the field from the post editor screen.
Use a custom shortcode in functions.php
to display the field value anywhere via [scf field="field_name"]
.
Step-by-Step Guide: Create SCF Field Using ACF Plugin
Step 1: Install & Activate ACF Plugin
- Go to Plugins > Add New
- Search for Advanced Custom Fields
- Click Install Now and then Activate
Step 2: Create a Custom Field Group
- Go to Custom Fields > Add New
- Give the field group a name like “Shortcode Field”
- Click Add Field
- Field Label: Example
My SCF Field
- Field Name: auto-generated like
my_scf_field
- Field Type: Choose Text, Textarea, or WYSIWYG Editor
- Field Label: Example
- Under Location Rules, set:
- Example: Post Type is equal to Post
- Example: Post Type is equal to Post
- Click Publish
Step 3: Add Field Content in Post/Page
- Edit any post or page
- You’ll see the new custom field at the bottom
- Enter your shortcode or dynamic content
Step 4: Display Field Using Shortcode
Add the following code in your theme’s functions.php
file or via a custom plugin:
function display_acf_field_shortcode($atts) {
$atts = shortcode_atts(array(
'field' => '',
'post_id' => get_the_ID()
), $atts);
$value = get_field($atts['field'], $atts['post_id']);
return $value;
}
add_shortcode('scf', 'display_acf_field_shortcode');
Step 5: Use the Shortcode Anywhere
Use the shortcode like this in a post, page, or widget:
[scf field="my_scf_field"]
Replace my_scf_field
with your actual ACF field name.