Display ACF Fields on the front-end

I’m a bit lost here. I successfully displayed the Custom Fields on the front-end using this code:

<?php acf_form_head(); ?>

<div id="form-fields">


    'post_id'       => 'new_post',
    'post_title'    => true,
    'post_content'  => true,


But this code only displays the fields of a regular post. I want to display some specific Fields that I have already created using the plugin and associated with a Custom Post.

Can someone please assist me through this

WooCommerce with ACF: custom fields per product variation

I’m a little stuck here. So I have variable products and I need to show the output of a custom field in a custom tab.

So I created a new field in ACF, called ‘test’. I’ve got this to work for the product itself, but the content does not change when I select another variable.

The code I have to add a ‘Post type’ = ‘Product variable’ in ACF.

add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) {
    global $abcdefgh_i; // Custom global variable to monitor index
    $abcdefgh_i = $loop;
    // Add filter to update field name
    add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
    // Loop through all field groups
    $acf_field_groups = acf_get_field_groups();
    foreach( $acf_field_groups as $acf_field_group ) {
        foreach( $acf_field_group('location') as $group_locations ) {
            foreach( $group_locations as $rule ) {
                // See if field Group has at least one post_type = Variations rule - does not validate other rules
                if( $rule('param') == 'post_type' && $rule('operator') == '==' && $rule('value') == 'product_variation' ) {
                    // Render field Group
                    acf_render_fields( $variation->ID, acf_get_fields( $acf_field_group ) );
                    break 2;
    // Remove filter
    remove_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
}, 10, 3 );

// Filter function to update field names
function  acf_prepare_field_update_field_name( $field ) {
    global $abcdefgh_i;
    $field('name') = preg_replace( '/^acf(/', "acf($abcdefgh_i)(", $field('name') );
    return $field;
// Save variation data
add_action( 'woocommerce_save_product_variation', function( $variation_id, $i = -1 ) {
    // Update all fields for the current variation
    if ( ! empty( $_POST('acf') ) && is_array( $_POST('acf') ) && array_key_exists( $i, $_POST('acf') ) && is_array( ( $fields = $_POST('acf')( $i ) ) ) ) {
        foreach ( $fields as $key => $val ) {
            update_field( $key, $val, $variation_id );
}, 10, 2 );

// Add "Product Variation" location rule values
function my_acf_location_rule_values_post_type($choices){

    $keys = array_keys($choices);
    $index = array_search('product', $keys);

    $position = $index === false ? count($choices) : $index + 1;

    $choices = array_merge(
        array_slice($choices, 0, $position),
        array('product_variation' => __('Product Variation', 'auf')),
        array_slice($choices, $position)

    return $choices;

add_filter('acf/location/rule_values/post_type', 'my_acf_location_rule_values_post_type');

// Add "Product Variation" location rule match
function my_acf_location_rule_match_post_type($match, $rule, $options, $field_group){

    if ($rule('value') == 'product_variation') {

        $post_type = $options('post_type');

        if ($rule('operator') == "==")
            $match = $post_type == $rule('value');

        elseif ($rule('operator') == "!=")
            $match = $post_type != $rule('value');

    return $match;

add_filter('acf/location/rule_match/post_type', 'my_acf_location_rule_match_post_type', 10, 4);

and the code for the tab is

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
    // Adds the new tab
    $tabs('test_tab') = array(
        'title'     => __( 'Shipping', 'woocommerce' ),
        'priority'  => 50,
        'callback'  => 'woo_new_product_tab_content'

    return $tabs;

function woo_new_product_tab_content() {

    // The new tab content

    echo 'New Product Tab';
    echo 'Here's your new product tab.';
        echo get_field('test', $post_id);

Can someone help me on my way with this? Much appreciated!!

Can I retrieve database table content with ACF plugin/custom fields?

Perhaps a silly question but I would want to retrieve data from some database tables (in WordPress). I’m using a template with WPBakery builder which let me output ‘custom fields’ on posts and pages.

Great for when I add a custom field (with ACF plugin) and I can display this data (if filled in) wherever I want. But is it also possible to get data stored in a database table when there’s not a custom field involved?

So for example, database table ‘livingroom’ has the options ‘length’, ‘width’, ‘height’ and for example the length is stored with to 1.80. Then I want to add this field to a single post.

Is there a way to point ACF in the right direction, by saying get the field ‘livingroom.lenght’ for this post? Or is it simple not possible to output the data this way?

I’ll get it to work with php but just wondering if I can use ACF for this.

Thanks for thinking with me!

advanced custom fields – ACF Schema doesn’t appear on actual pages? Elementor

normally I install an advanced custom field on my pages registering this:

<?php if( get_field('schema_object') ): ?>
    <script type="application/ld+json"><?php the_field('schema_object'); ?></script>
    <?php endif; ?>

and it works fine.
I’ve installed that very function on the header.php file but the content of the custom field (a schema markup) isn’t appearing in my head section, how do I fix this?

I’m using Elementor.

filters – Get users based on month ACF datepicker field

I have an ACF field ‘date_of_birth’ which stores the user’s birthday, examples: 20201226, 20151225, 19980701

Goal: get all users which have their birthday this month, or next month.

I currently have this:

    $users_start_date_boundary = gmdate( 'Ymd', strtotime( '-1 month' ) );
    $users_end_date_boundary   = gmdate( 'Ymd', strtotime( '+2 month' ) );

    $wp_user_query = new WP_User_Query(
            'fields'     => 'all_with_meta',
            'orderby'    => 'date_of_birth',
            'order'      => 'ASC',
            'meta_query' => (
                    'key'     => 'date_of_birth',
                    'value'   => ( $users_start_date_boundary, $users_end_date_boundary ),
                    'compare' => 'BETWEEN',
                    'type'    => 'DATE',

    return $wp_user_query->get_results();

The problem with this however, that it only gets users with a birthyear of 2020.

How do I get all users, based on the given month boundaries, while ignoring the year/day the person is born in?

php – Order posts by hour with ACF and Timber (TWIG)

First of all I use ACF and Timber (TWIG).

I’m trying to create a calendar with a classification by year, month and hour.

I created a custom ACF field : event_date and an another field for start time event_hour_start

How I can order posts by hour for each month please ?


  • November
    • First event – 14:00
    • Second event – 16:00
  • December
    • First event – 11:00
    • Second event – 12:00


$events = Timber::get_posts(array(
    'post_type' => 'events',
    'meta_key'  => 'event_date',
    'orderby'   => 'meta_value_num',
    'order'     => 'DESC'

$events_list = array();

if($events) {
    foreach($events as $event) {
        $date = get_field('event_date', $event->ID, false);
        $hour_start = get_field('event_hour_start', $event->ID, false);
        $hour_end = get_field('event_hour_end', $event->ID, false);

        $date = new DateTime($date);

        $year = $date->format('Y');
        $month = $date->format('F');

        $events_list($year)($month)() = array($event, $date, $hour_start, $hour_end);

$context('events_list') = $events_list;


{% for year, years in events_list %}
    <p>Year : {{ year }}</p><br>
    {% for month, months in years %}
        <p>Month : {{ month }}</p>
        {% for event, events in months %}
            <p>{{ events(0).post_title }}</p><br>
        {% endfor %}
    {% endfor %}
{% endfor %}

Make “ACF V4 star rating field type” compatible for Advaced custom fields 5

Hello every body i want to make this ACF 4 Star rating plugin compatible for ACF 5. Who can help me please.
I installed the plugin but i can not see star rating field among other field types. This is plugin link.

// Include field type for ACF4
function acf_srf_register_fields() {
add_action('acf/register_fields', 'acf_srf_register_fields');   

I will install Element Pack, Astra Agency, Crocoblock, ACF Pro, and PowerPack for Elementor for $5

I will install Element Pack, Astra Agency, Crocoblock, ACF Pro, and PowerPack for Elementor

Hello, my name is Irfan Quttab and I am providing a WordPress Theme and Plugins installation service.

If you are a freelancer we offer the installation of Paid Membership Pro, Astra Agency Bundle, Crocoblock, Advanced Custom Field Pro, Element Pack Addon, Piotnet Addon, Powerpack Addon For Elementor, Avada theme, Divi Theme, etc for you or any client website.

We know that when you start working on this many freelancers do not justify buying Crocoblock or Astra Agency on their own for one client or site. That is why we offer the installation service for all our customers, and for the customers of our customers.

Basic Package (INSTALLATION in $5)

Element Pack

Astra Agency Bundle

Advanced Custom Field Pro (ACF)

Standard Package (INSTALLATION in $10)

Element Pack

✅ Astra Agency Bundle

✅ Advanced Custom Field Pro

Crocoblock for Elementor

Piotnet Addons for Elementor

Power Pack Addons for Elementor

✅ Paid Membership Pro

Premium Package (INSTALLATION in $15)

✅ Element Pack

✅ Astra Agency Bundle

✅ Advanced Custom Field Pro

✅ Crocoblock for Elementor

Piotnet Addons for Elementor

✅ Power Pack Addons for Elementor

✅ Paid Membership Pro

✅ Divi Full Bundle

✅ Avada Theme


advanced custom fields – ACF – Compare Products Feature


I have created Product pages with their respective specifications using ACF.

Now, i would like to add a product comparison feature with 2 or 3 products.

Upon research, i found that a Compare input field is needed beside every product in the Products Page and this information has to be passed on to the Comparison page.

There are many steps to achieve the final working model.

Can anyone guide me with the steps along with codes to get started?