itsmeit.bizitsmeit.biz
  • Home
  • Windows
    • Windows Software
  • Ubuntu & Linux
    Ubuntu & Linux
    The top blog articles on Ubuntu and Linux, featuring valuable tips and tricks, empower you to master these operating systems and enhance your experience.
    Show More
    Top News
    How to Remove Ubuntu Dual boot Windows 11 UEFI and Legacy
    How to Remove Ubuntu Dual boot Windows 11 UEFI and Legacy
    November 10, 2023
    How to install php7.4 on Ubuntu & Config php7.4-fpm - itsmeit.biz
    How to install php7.4 on Ubuntu 22.04 | 20.04 LTS
    November 10, 2023
    Install Ubuntu dual boot Windows 11 | 10 UEFI And Legacy
    Install Ubuntu dual boot Windows 11 | 10 UEFI & Legacy
    November 10, 2023
    Latest News
    How to install Composer on Ubuntu 20.04 | 22.04 & Linux
    November 13, 2023
    How to Configure Redis Cache to Speed ​​Up WordPress Site
    November 15, 2023
    Install Ibus-bamboo or Ibus-unikey for Accented Letters on Ubuntu 22.04
    November 11, 2023
    How to install MariaDB on Ubuntu 22.04, 20.04 and Debian
    November 11, 2023
  • Web developer
    • Wordpress Theme
      • Blog News
      • Fashion Theme
      • Theme Elementor
      • WooCommerce Theme
    • Wordpress Plugin
    • Magento Developer
Reading: How to Add Custom Fields (ACF) & Display Data in Post WordPress
Share
Font ResizerAa
itsmeit.bizitsmeit.biz
Font ResizerAa
  • Linux & Ubuntu
  • Windows
    • Tips & Trick
    • Windows Software
  • Web developer
    • Magento Developer
    • Wordpress Plugin
    • WP Blog Theme
    • WP Fashion Theme
    • WooCommerce Theme
  • Log Out
Have an existing account? Sign In
Follow US
Copyright © 2022. All Rights Reserved.
Web developer

How to Add Custom Fields (ACF) & Display Data in Post WordPress

duyanh
Last updated: November 15, 2023
By duyanh Published November 12, 2023
Share
SHARE

Table of contents

  1. How to Add Custom Fields & Display Data (ACF) in Post or Product WordPress
    1. Step 1: Install the plugin and create your own fields
    2. Step 2: How to use Advanced Custom Fields (ACF) to add data
    3. Step 3: Display the ACF Fields outside the product or article page
    4. Link download: Advanced Custom Fields Pro | Full Document (ACF)

Advanced Custom Fields is really flexible to create and manage custom fields in posts, pages or products in WordPress. ACF Pro is mainly focused on creating and managing custom fields in the backend. This includes creating custom fields, displaying rules, and storing data.

However, to display data from custom fields created with ACF Pro on the front end, you will need to code it yourself or customize your interface. In this article ItsmeIT shares how to add custom fields and display Advanced Custom Fields (ACF) data outside the Frontend like on articles or products…

How to Add Custom Fields & Display Data (ACF) in Post or Product WordPress

Step 1: Install the plugin and create your own fields

Download and install the latest Advanced Custom Fields Pro (ACF) plugin. Then click on ACF in the menu and start creating custom fields. In this tutorial, ItsmeIT will give an example to create a “Download Link” field.

How to Add Custom Field & Display Data (ACF) in Post or Product Wordpress
Add Custom Field & Display Data (ACF) in Post or Product Wordpress (illustration)

After creating the field and saving it, you will have a custom field in the article with the field name “link_download”, we will rely on it to be able to display Advanced Custom Fields data to the front. Since a link will have to come with a title for it. So ItsmeIT will click “Add Field” to continue creating one more field to save for the title:

how to add custom field display data acf in post wordpress 2

Continue, item “Settings”. You can configure the condition to use only this “Group Field” which will be used to display Advanced Custom Fields data for the post or product or page you want.

how to add custom field display data acf in post wordpress 3

Step 2: How to use Advanced Custom Fields (ACF) to add data

After completing step 1, you can now open edit or add a new post or product. Scroll down to the bottom you will see “Field Group” of ACF. Here you can add your custom data.

How to use Advanced Custom Fields (ACF) to add data

Note that this is an illustrative example to get and display data from Advanced Custom Fields (ACF) custom fields outside the front like posts or products. It is similar to other schools. You can create “Field Type” like textarea, select, checkbox, WYSIWYG Editor…

Step 3: Display the ACF Fields outside the product or article page

In this tutorial, ItsmeIT will use PHP code and leverage a the_content hook available in WordPress to insert custom data into Wordpress posts.

Open the functions.php file in the theme you are using and start coding. Now look back at step 1, after creating “Field Group”, ItsmeIT already has 2 fields named link_download and link_title. Thereby we will use the function get_field to call it and display the data as follows:

<?php
// Add custom Theme Functions here

add_filter('the_content', 'render_html_post_content');
function render_html_post_content($content) {
    $post_id = get_the_ID();
    if (!isset($post_id)) {
        return $content;
    }

    $link_download = get_field('link_download', $post_id);
    $link_title = get_field('link_title', $post_id);

    if (!empty($link_download) && !empty($link_title)) {
        $link_html = '<h3>Link download: ';
        $link_html .= '<a href="' . esc_url($link_download) . '">' . esc_html($link_title) . '</a>';
        $link_html .= '</h2>';
        return $content . $link_html;
    }

    return $content;
}

The code above ItsmeIT used the_content and added custom content from Advanced Custom Fields (ACF) at the end of the article. Along with the conditions execute the code only if ACF has data in the article and only display it according to that article’s Purpose so that it doesn’t affect the performance of other articles. And the screenshot below is the result.

how to add custom field display data acf in post wordpress 5

With Advanced Custom Fields Pro, you have the flexibility to create and manage custom fields and display custom data on your WordPress site. This helps you create custom websites and extends the capabilities of your CMS content management system.

Link download: Advanced Custom Fields Pro | Full Document (ACF)

– Advertising –

Share this Article
Facebook Twitter Pinterest LinkedIn Reddit Telegram
Leave a comment Leave a comment
Subscribe
Connect with
Login
Notify of
guest
Connect with
guest
0 Comments
Inline Feedbacks
View all comments
Previous Article How to Configure Redis Cache to Speed ​​Up WordPress Site How to Configure Redis Cache to Speed ​​Up WordPress Site
Next Article Download Advanced Custom Fields Pro v6.2.2 (ACF) WordPress plugin Download Advanced Custom Fields Pro v6.2.2 (ACF) WordPress

You Might Also Like

Prevent Spam Register Plugin – Block WordPress Spam Accounts

How to Disable and Secure WP JSON API in WordPress

How to install Magento 2.4 on Ubuntu 22.04 with Composer

How to fix errors & change all WordPress links to a new domain

Newsprk v6.1.0 – WordPress theme Magazine and Blogs

Stay Connected

Facebook Like
Twitter Follow
Pinterest Pin
Telegram Follow

Popular Posts

Download IDM FULL Crack v6.42.2 + Repack (Fix fake serial)
Download IDM FULL Crack v6.42.2 + Repack (Fix fake serial)
December 8, 2023 675 Views
Download WPBakery v7.2 Drag and Drop WordPress Page Builder Plugins
WPBakery v7.2 Drag and Drop WordPress Page Builder Plugins
December 4, 2023 25 Views
Download Plugin Product Video Gallery for Woocommerce v1.5.0
Plugin Product Video Gallery for Woocommerce v1.5.0
November 17, 2023 10 Views
Download Prevent Spam Register Plugin - Block WordPress Spam Accounts
Prevent Spam Register Plugin – Block WordPress Spam Accounts
November 17, 2023 15 Views
Elementor PRO v3.17.0 Plugin (Full Templates Pack + Demo)
Download Plugin Elementor PRO 3.17.0 (+Full Templates Pack)
November 17, 2023 38 Views
Download Newspaper v12.6.1 - WordPress theme News Magazine
Download Newspaper v12.6.1 – WordPress theme News Magazine
November 17, 2023 18 Views
We provide tips and tricks on Internet technology, computers, servers as well as share experiences for developers and website designers.

DMCA.com Protection Status

Quick Link

  • Linux | Ubuntu
  • Windows & Software
  • Magento Developer
  • Wordpress Plugin
  • Wordpress Theme

General Policy

  • About US
  • Contact US
  • Disclaimer
  • Privacy Policy
  • Terms of Service

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

itsmeit.bizitsmeit.biz
Follow US
Copyright © 2023. All Rights Reserved.
  • WP Blog Theme
  • WP Fashion Theme
  • WooCommerce Theme
  • Wordpress Plugin
Welcome Back!

Sign in to your account

Continue with Google
Continue with TikTok
Continue with GitHub
Register Lost your password?