ACF Field Not Displaying on Front End: Additionally, I’ve noticed that one of the ACF fields is not displaying on the Front End of my website, despite being set up correctly. I’m using Elementor and the Astra theme, both on their latest versions.
PRO.
Current Version 6.3.5
Any additional information on how to fix these problems would be greatly appreciated.
As of today a post object field which is set to return published posts from a single custom post type has stopped displaying data in its select field in the admin area. It was working fine previously, and nothing has changed that I’m aware of, no updates, no alterations to the settings.
Instead I am getting the message “the results could not be loaded”.
– This field is within a repeater field.
– The previous instances still show their values.
– I have checked the console and I don’t see any errors being logged.
I’m not sure how to fix this. Can anyone help please?
Hi all, recently I upgraded the wordpress (WordPress 6.7.1) & ACF (Version 6.3.11) plugin version to latest. After then a page than is using Repeater Field Type, one of the field cannot be saved (see cannot save.PNG). I check the POST data that WP the “cover” data is empty even I selected the image. So that I try to check the Field Group, then the sub-field is displaying not my expect.
The wordpress was not my origin project, I’m taking over that, so I’ve no idea what is the problem.
P.S. The wordpress didn’t pay for the ACL Pro, I’m not sure whether it cause the sub-field weird
Hello. I have a site with multiple authors. I have created a “Team” page where I want to show different author blocks on the same page. I have created two author blocks with GenerateBlocks and ACF. I have used Generate Block’s element which pulls meta data from their user profile pages on WordPress – author.png
I have created ACF author fields that create the Custom Post Fields for GenerateBlocks – acf author fields.png
However, I cannot figure out how to show both authors on the same page using ACF and Generate Blocks on my front end “Team page” WP keeps defaulting to the logged-in user and displaying two identical custom post fields with the same meta data.
People have suggested another plugin to handle multiple authors but I am sure I can do this with ACF Pro and Generate Blocks pro?
Please advice with detailed explanation as I have tried everythig else.
Thanks
Hello and thanks in advance for the help!
I have a flexible content field nested in a repeater field’s foreach loop. It is not displaying when I use the method prescribed in the documentation (if, while statements).
I’m assuming that it would work if it was a nested foreach statement instead? But, I’m not sure or you’re even able to use foreach with the flexible content field.
I am doing it this way in an effort to have access to values from the previous repeater row as discussed here: https://support.advancedcustomfields.com/forums/topic/get-value-from-next-row-in-repeater/
I am trying to setup a word press site to list available animals for an animal rescue. I have the pages set up and i have created a custom post type as well ad custom fields with the Advanced Custom Fields plugin. The fields have things like name, bio, age and a picture. no title is required. i have the Spectra editor installed and have added the Post Grid block to the page and connected the post grid to the available animals post type but the posts are not displaying
The post type in ACF is public and active and adding a new post works and i can go back and review the data. I just am not seeing the post display in a grid on the page.
Hi everyone. I really need your help with a rather simple scenario I am trying to tackle.
I am using Elementor PRO and I have created two CPTs with ACF.
The first CPT is ‘Portfolio Items’ with fields like “Client Name”, “Logo”, “Project Details” etc. and the second CPT is ‘Testimonials’ with fields like “Name and Surname”, “Position” and “Testimonial text”.
I created a template for the Portfolio Items which is assigned to show on the Portfolio custom post type.
I also want to display the testimonial’s custom fields inside the portfolio template but even if I select the testimonial fields in the Elementor ACF dropdown, the fields are not displaying on the frontend.
I have tried the relationship fields, post object, clone but nothing seems to work. Sorry if this has been asked a gazillion times but I couldn’t find how to achieve this.
Thanks!
Hi guys i am developing a plugin for my own purpose nothing commercial, it’s just a way to automate my future work and I am facing something peculiar, I admit I am not using the latest version of ACF because I am developing on localhost, I am not willing to use my licence on a localhost environment.
So this is not necessary a technical issue, I mean is something between frontend a backend, I admit I am able to fix this somehow but I need to know if there is a propper method to do it:
I have a big repeater field and there are conditions all around it, when it comes to display fields based on these conditions, will mess things around, spacings, etc.
this is the json Fields :
acf_add_local_field_group(array(
'key' => 'group_66125eef10578',
'title' => 'Slideshow',
'fields' => array(
array(
'key' => 'field_6614259e8d6f3',
'label' => 'Slideshow',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_661435860c17d',
'label' => 'Slideshow Post type',
'name' => 'slideshow_post_type',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'multimedia' => 'Multimedia',
'products' => 'Products',
'gallery' => 'Gallery',
'posts' => 'Posts / Pages / Custom CTPS',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_66125ef55e8f9',
'label' => 'Slides',
'name' => 'slideshows',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_661435860c17d',
'operator' => '==',
'value' => 'multimedia',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 0,
'layout' => 'table',
'button_label' => '',
'sub_fields' => array(
array(
'key' => 'field_66125f765e8fa',
'label' => 'Slide Type',
'name' => 'slide_type',
'type' => 'select',
'instructions' => 'Select the type of the slide you want to display',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'choices' => array(
'image' => 'Only Image',
'video' => 'Only Video',
'custom' => 'Custom Slide',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_6612a963f9b30',
'label' => 'Slide Custom Background',
'name' => 'slide_custom_background',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_66125f765e8fa',
'operator' => '==',
'value' => 'custom',
),
),
),
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'choices' => array(
'image' => 'Image background',
'video' => 'Video background',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_6614add9153df',
'label' => 'Apply overlay',
'name' => 'apply_overlay',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_6614adfb153e0',
'label' => 'Overlay color',
'name' => 'overlay_color',
'type' => 'color_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_6614add9153df',
'operator' => '==',
'value' => '1',
),
),
),
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'default_value' => '',
'enable_opacity' => 1,
'return_format' => 'string',
),
array(
'key' => 'field_661260ac186f8',
'label' => 'Slide Image',
'name' => 'slide_image',
'type' => 'image',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_66125f765e8fa',
'operator' => '==',
'value' => 'image',
),
),
array(
array(
'field' => 'field_66125f765e8fa',
'operator' => '==',
'value' => 'custom',
),
),
array(
array(
'field' => 'field_6612a963f9b30',
'operator' => '==',
'value' => 'image',
),
),
),
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'preview_size' => 'medium',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
array(
'key' => 'field_6612a83ca59b6',
'label' => 'Slideshow Video',
'name' => 'slideshow_video',
'type' => 'url',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_66125f765e8fa',
'operator' => '==',
'value' => 'video',
),
),
array(
array(
'field' => 'field_6612a963f9b30',
'operator' => '==',
'value' => 'video',
),
),
),
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
),
array(
'key' => 'field_6612a74c96a57',
'label' => 'Slideshow Text',
'name' => 'slideshow_text',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_66125f765e8fa',
'operator' => '==',
'value' => 'custom',
),
),
),
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
'delay' => 0,
),
array(
'key' => 'field_6612a76a96a58',
'label' => 'Slideshow Text orientation',
'name' => 'slideshow_text_orientation',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_66125f765e8fa',
'operator' => '==',
'value' => 'custom',
),
),
),
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'choices' => array(
'left' => 'Align Left',
'right' => 'Align Right',
'center' => 'Align Center',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_6614277a8d6fa',
'label' => 'Slideshow interval',
'name' => 'slideshow_interval',
'type' => 'number',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '20',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => '',
'max' => '',
'step' => '',
),
),
),
array(
'key' => 'field_6614b1ec5fc8f',
'label' => 'Gallery Slides',
'name' => 'gallery_slides',
'type' => 'gallery',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_661435860c17d',
'operator' => '==',
'value' => 'gallery',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'preview_size' => 'medium',
'insert' => 'append',
'library' => 'all',
'min' => '',
'max' => '',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => '',
),
array(
'key' => 'field_661425b48d6f4',
'label' => 'Options',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array(
'key' => 'field_661425d48d6f5',
'label' => 'Slideshow Height',
'name' => 'slideshow_height',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'choices' => array(
'px' => 'Pixels',
'vh' => 'View Port Height',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
array(
'key' => 'field_661426208d6f6',
'label' => 'Height Number',
'name' => 'height_number',
'type' => 'number',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => '',
'max' => '',
'step' => '',
),
array(
'key' => 'field_6614ad39baef8',
'label' => 'Inherit theme colors',
'name' => 'inherit_theme_colors',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_6614264e8d6f7',
'label' => 'Display Arrows',
'name' => 'display_arrows',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_6614acf4baef6',
'label' => 'Arrow Color',
'name' => 'arrow_color',
'type' => 'color_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_6614ad39baef8',
'operator' => '!=',
'value' => '1',
),
),
),
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'default_value' => '',
'enable_opacity' => 1,
'return_format' => 'string',
),
array(
'key' => 'field_661426618d6f8',
'label' => 'Display Indicator',
'name' => 'display_indicator',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_6614ad1bbaef7',
'label' => 'Indicators color',
'name' => 'indicators_color',
'type' => 'color_picker',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_6614ad39baef8',
'operator' => '!=',
'value' => '1',
),
),
),
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'default_value' => '',
'enable_opacity' => 1,
'return_format' => 'string',
),
array(
'key' => 'field_661426ca8d6f9',
'label' => 'Slideshow Sliding Effect',
'name' => 'slideshow_sliding_effect',
'type' => 'select',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '33.3',
'class' => '',
'id' => '',
),
'choices' => array(
'normal' => 'Normal Slide / Swipe',
'fade' => 'Fade in Slide',
),
'default_value' => false,
'allow_null' => 0,
'multiple' => 0,
'ui' => 0,
'return_format' => 'value',
'ajax' => 0,
'placeholder' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'evx_slideshow',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
));
endif;
This is the image with the mess it brings :
In advance, i don’t need to help me developing a solution, i just need to know if there is something you guys know how to easy deal with or if i mistake something in my implementation of displaying these fields.
Cheers, Lucian.
I’ve introduced a new post type in WordPress named “car” where I showcase the specifications of various cars. I’ve extensively utilized Advanced Custom Fields (ACF) with numerous fields for all the specifications and details.
In the page-price.php template:
I’ve additionally created a new group field for the car prices on a page where I list all the cars and set their prices. Now, I aim to input the identifier for each car in that list to display the prices on the “car” post type page.
My objective is to manage and update price changes for each car on a single page, ensuring that the modifications reflect across all different car specification pages. I’m also looking to avoid the hassle of individually editing all posts related to the 200 cars.
Will this potentially lead to slow loading of the car specification pages?
How can I display the price of each car on the single post page of each car?
<div class="car-price">
<?php
$current_car_id = get_the_ID(); // this car id
if (have_rows('pr-price')):
while (have_rows('pr-price')): the_row();
if (have_rows('pr-p-list')) :
while (have_rows('pr-p-list')): the_row();
$car_id_in_price_table = get_sub_field('pr-p-i-id');
if ($car_id_in_price_table == $current_car_id) :
// show price of car
echo get_sub_field('pr-p-i-co');
endif;
endwhile;
endif;
endwhile;
endif;
?>
</div>
I’ve used this code in my single-car.php, but it’s not functioning. How should I proceed to resolve this?
Hi, I can’t seem to be able to display the repeater field and would love to understand why. All help is much appreciated! This is the code I’m using:
<div class="infusion-ingredientes-iconos">
<?php if ( have rows ('infu_ingredientes_iconos') ) : ?>
<ul>
<?php while( have_rows ('infu_ingredientes_iconos') ) : the_row(); ?>
<img src="<?php get_sub_field('infu_ing_icono');?>" />
<div>
«span class="infu-ing-titulo"><?php get_sub_field('infu_ing_titulo');?></span>
<a href="<?php get_sub_field('infu_ing_link' );?>"><?php get_sub_field('infu_ing_btn');?></a>
</div>
<?php endwhile; ?>
<?php endif: ?>
I am trying to support a client whose site I did not build, where almost all content is created through ACF field groups. They have a predicatable issue with the recent escaping html change, where an embedded form from a third-party vendor that was inserted into a WYSIWYG field is no longer displaying.
I need to add the escape html instruction to this field, but can’t figure out where to add it. I don’t see a setting in the ACF Field Groups interface where the WYSIWYG field is made available for use in the page template.
If there isn’t a way to resolve this in the ACF plugin UI, I do have access to edit the template files, so am open to suggestions there too.
Thanks
I have a field group that is for a post in a particular category
I am using the [acf_form form_id=”adscasfASFDAsf”] shortcode on the front end.
For creating a new post, as the form doesn’t know its in a particular category it doesn’t display the field group fields
I have tried adding new_post=”post_type|post,tax_input|my-category” to the shortcode but that doesn’t make it display the fields before the post is assigned to the category.
Is there a way to get it to display the fields?
Hi,
This is an important issue for all website builders. Image rights agencies nowadays scour the web looking for stock photos/images whose copyright notice has not been published according to the proper rules and then present them with a hefty bill.
So it is more important than ever to have a correct copyright notice with the photos on your website. Unfortunately, the WordPress Media Library does not provide a field for this. You can add it quite easily with ACF and link it to the Media Library with the rule ‘Attachment > all image formats.’ If only it would works so easily.
On a website I’m building in Divi (one of the builders supporting ACF), I did this to be able to automatically show the photographer and stock photo platform in the front end for featured images.
In the template for displaying posts, I have added a text module with the ACF Copyright field as content (Divi is one of the website builders supported by ACF).
When I create a post, the design of this template is automatically applied. However, the content of the Copyright field is not displayed. Am I overlooking something?
Kind regards,
Pierre Gielen
This might be a daft question, is there a way to display a live value on a page.
For example I have the field ‘status’, is there a way of displaying the live value without refreshing the page. So if a user updates this on the back end, the front end user sees the updated value without refreshing the page.
Alternatively if not possible and someone updates a specific field it forces a refresh on the front end.
Hope this makes sense, and any pointers greatly appreciated.
Hello, I have a new CPT called “person”. This will have ACF fields containing the name, thumbnail, bio and further info of each person at my client’s company.
I’m also creating a team member grid element where individual people can be chosen from the people CPT using an ACF Post Object field, displaying the thumbnail and name.
BUT some of these people will have their own page showing all their details, while other will not have a page at all, just the thumbnail and name with no link. I will create a single-person.php template to show all their details but I need to make sure that this only used when conditionally chosen in the person’s admin screen.
What I need to do is have a conditional true/false field in the person’s admin screen which is called “Has own page?”. I want to 404 any attempt to land at a page where this conditional has not been set.
Good: /people/the-boss/ Has own page?: Y
404: /people/the-intern/ Has own page?: N
I was wondering if I should place the logic for this inside the single-person.php template, or if it’s better to do it earlier somehow so that this single page template isn’t touched and the 404.php template is used immediately.
Another concern I have is for things like Yoast sitemap which could ignore the page templates completely and create links for people I do not want.
What is my best approach for conditionally setting a 404 for some people and not others?
Thanks in advance.
I have a CPT with CF’s. I have made a change to the data in one of the Custom fields in an existing post, and it does not show the changes in data on my website. It seems like the browser is just loading from cache and not grabbing the new data. I am displaying data based on a query loop in bricks builder if that makes a difference.
Hi there! Thanks in advance for the great plugin.
Here’s my issue:
1. I’ve taken over a site that makes extensive use of the fields feature.
2. I have added a new layout to the existing flexible field and wish to test it by adding it to a page, but when I hit publish (on staging) the new field does not display when I load the page (it can however be successfully saved).
3. I can confirm that it is possible for example to duplicate existing filled-out fields (in the page editor) in which case they do show up.
4. I fear there is some setting on my new field that I have misconfigured that causes it to be omitted when displaying the page.
Some background on the set up:
1. The pages on our site all have a single field, of the type “Flexible Content”
2. It includes various types.
3. I have added my own layout, consisting of a title and an image gallery.
I have tried a hard refresh.
Any thoughts?
I’m using ACF with Avada theme, and have lots of ideas with this fantastic plugin.
I have’ however met some problems. I’m using Avada and is not programming the pages.
1 – Trying to display a field below a group, but hasn’t succeded. I can get an array if I use the select version and select only group name.
2 – Trying another approach I tried to make filds display on products hith a certain category, but cant select product categries anywhere.
What I want is to make different fields for different product types.
Example. A car Has fields value, mileage, brand, windows. A MC has fields, value, mileage, brand but no windows. Another product should have just fields value and a text.
Hi,
On my site I have the following:
The idea is that I can use the relationship field to select an author in Book Reviews. This is working.
However, I cannot figure out how to display the author info (pulled from the “Book Author”) in the Book Review on the frontend. When I use the “Custom field finder” plugin to see what info is in the Book Review post, all I see is the Book Author post ID I selected. I’ve tried to set the “Return format” to Post Object and Post ID, with the same result: only the post ID is returned.
I’ve been trying to use Kadence Elements to display this info, but all it can see is the Book Author post ID.
Is there anything that will pull all the info (author name, image, bio) from the selected Book Author?
Hi there! I’m not a developer, just a Dad that is trying to create a cool website for his Jazz Musician son. While I’m using Elementor, I’m also trying to minimize plugins. That said, I’ve created a Custom Post Type called “Gigs” to dynamically highlight upcoming shows that my son will be playing. I’ve also created a Custom Taxonomy called “Locations” to dynamically bring in Map, Location URL, and Image for instance. I cannot get any of these custom fields associated with the Locations Taxonomy to display. I’ve also created a second CPT called “Gig Locations” and tried to relate them to the Gigs CPT so that I could display its respective custom fields.
I can place an ACF Google Maps field directly in the Gigs CPT and it will display through the Elementor Google Maps widget. But the ACF Google Maps fields in either the Taxonomy or 2nd CPT will not display. When attempting to put custom PHP code snippets to “get_meta_terms” etc., nothing happens or the site crashes entirely.
Thanks in advance for your help!
qthornton.com
Hello ACF Support,
I’m encountering a challenge with nested Advanced Custom Fields (ACF) repeater fields on my WordPress site, specifically involving conditional logic and how it’s handled on the front end.
Setup:
I have a nested structure in my ACF fields, where plaintiff_injury_part_1 is a select field within a repeater field plaintiffs_injuries, which itself is nested within another repeater field plaintiffs_test.
The plaintiff_injury_part_1 field is a select dropdown that triggers conditional logic, displaying different injury types ( amputation, and abdomen which is abbreviated to “abdo” etc.) based on the selection.
Each injury type is a select field within the same repeater row.
Issue:
When an editor changes the injury type from one category to another (e.g., from abdo to amputation), the front end still displays both the new and the previous selections, instead of just the updated one.
I have implemented JavaScript to set the non-selected injury field to null when a different injury type is selected, and this seems to work in the admin area (the non-selected injury field resets to its default ‘-Select-‘ option). However, the front end still shows both injuries.
I’ve also modified my shortcode that outputs these fields to check for null values, yet the issue persists.
What I Need:
I’m looking for a way to ensure that when an injury type is updated in the backend, only the latest selection is reflected on the front end, and any previous selections under different injury types are not displayed.
Code Samples:
Here is the code for creating the short code for these fields (there is some debugging language left in there):
<?php
function acf_repeater_field_shortcode_plaintiff($atts) {
global $post;
if (!$post) return 'No global post object available';
$atts = shortcode_atts(
array(
'field' => 'plaintiffs_test',
),
$atts,
'acf_repeater_field_plaintiff'
);
$output = '';
if (have_rows($atts['field'], $post->ID)):
while (have_rows($atts['field'], $post->ID)): the_row();
$output .= '<div class="repeater-item">';
// ... other fields ...
if (have_rows('plaintiffs_injuries')):
while (have_rows('plaintiffs_injuries')): the_row();
$output .= '<div class="plaintiffs_injuries">';
// Debugging lines
$amputation = get_sub_field('amputation');
$abdo = get_sub_field('abdo');
$output .= "<p>Debug Amputation: " . esc_html(var_export($amputation, true)) . "</p>";
$output .= "<p>Debug Abdo: " . esc_html(var_export($abdo, true)) . "</p>";
// Check for non-null and non-'null' values
if (!empty($amputation)) {
$output .= '<p><strong> Amputation Injury: </strong>' . esc_html($amputation) . '</p>';
}
if (!empty($abdo)) {
$output .= '<p><strong> Abdominal Injury: </strong>' . esc_html($abdo) . '</p>';
}
$output .= '</div>';
endwhile;
endif;
$output .= '</div>'; // Close .repeater-item div
endwhile;
else:
$output = 'No data found in the ACF Repeater Field.';
endif;
return $output;
}
// Now the shortcode
add_shortcode('acf_repeater_field_plaintiff', 'acf_repeater_field_shortcode_plaintiff');
And here is the javascript created to void the field that is not selected, when one makes a new choice.
function my_acf_admin_custom_js() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Trigger this when an ACF field within a repeater changes
$(document).on('change', '.acf-repeater [data-name="plaintiff_injury_part_1"] select', function(e) {
var $thisSelect = $(this);
var $repeaterRow = $thisSelect.closest('.acf-row');
var selectedValue = $thisSelect.val();
// Reset the 'abdo' field if 'amputation' is selected, and vice versa
if(selectedValue === 'amputation') {
$repeaterRow.find('[data-name="abdo"] select').val('').trigger('change');
} else if(selectedValue === 'abdo') {
$repeaterRow.find('[data-name="amputation"] select').val('').trigger('change');
}
});
});
</script>
<?php
}
Any guidance or insights into what might be causing this behavior and how to resolve it would be greatly appreciated. Thank you for your assistance!
Hi.
I have been working on creating a select field in Advanced Custom Fields (ACF) where the choices are dynamically populated based on a textarea input in a fixed page. I followed the guide on “Populating Choices From a Repeater Field” from the ACF documentation here: [https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/](https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/).
In the textarea, I’m inputting choices in the following format:
`
value_abc : LABEL_ABC
value_xyz : LABEL_ZETTN
`
When I edit the textarea to add choices, the labels appear correctly in the post edit screen and are selectable.
However, when the post is published and I use get_field()
to display the data, it shows the value instead of the label. This is not the expected behavior, as I would prefer the label to be displayed.
Could you advise on what might be missing or required in the theme or ACF settings to correctly display the label instead of the value?
As an additional note, after some trial and error, I found that exporting and then re-importing ACF settings seemed to correct the issue and the labels displayed as expected. I hope this information might be helpful in diagnosing the issue.
Thank you for your assistance.
Hello everyone,
I have been trying all day to have FlexSlider work with Advanced Custom Fields Pro. I got the slider to work, but the image will not display. Here is my code below, any help would be greatly appreciated.
<?php if( have_rows('banner') ): ?>
<div class="flexslider">
<ul class="slides">
<?php while( have_rows('banner') ): the_row();
$image = get_sub_field('slide');
$title = get_sub_field('title');
?>
<li><img />" alt="<?php echo $title;?>"></li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>
I am trying to use an ACF text field in a <object> tag, but it is not rendering.
I am using a CodeBlock in WP to display a PDF inline on the page, but I can’t get the ACF tag to work inside an object tag. What I have is:
=== begin code block ===
PDF File URL: [acf field="resource_file_url"]<br>
<object
data=”[acf field="resource_file_url"]”
type=”application/pdf”
width=”100%”
height=”700″>
</object>
=== end code block ===
In the above example, the file URL is displayed on the page, but not inside the object tag (viewing the SRC, it is blank). Does anyone have a way to do this? I have tried different methods of displaying the ACF field too, and none of these work either inside the tag (while some do display the URL):
[acf field="{$resource_file_url}"]
[acf field='resource_file_url']
[acf field={resource_file_url}]
[acf field={$resource_file_url}]
[acf field={"resource_file_url"}]
[acf field=resource_file_url]
[acf field="{$resource_file_url}"]
I’m creating a company directory page, where I’m querying all users on he site and displaying their info. Some info is generated from ACF on user profiles. My user loop works great. I’m able to retrieve field data for some of my fields, however, I cannot get the User object field (Manager) to display properly. within ACF, i have this field set to return the User ID. Ultimately I just want the display name of the “Manager”.
WHen trying to return the User Object, instead of the ID, it breaks the site.
Within my user query, I’m using the following:
$args = array('orderby' => 'display_name',);
$users = get_users($args);
foreach($users as $user){
$userID = 'user_'.$user->ID ;
echo '<li>';
echo '<b style="font-size:14px;">' . $user->data->display_name . ' x' . $user->emp_office_ext . '</b><br/>';
echo '<em style="font-size:12px;white-space: nowrap; ">' . get_field('position',$userID) . '</em>';
if (!empty(the_field('manager',$userID))){
$managerID = get_field('manager',$userID);
$managerData = get_userdata($managerID);
$manager = $managerID->display_name;
echo $manager;
}
echo '</li>';
}