Another issue that could be causing this is that something is outputting something, and this could even be just white space, before ACF sends a response to the AJX request. Issues of this kind are extremely difficult to track down. It can be a plugin conflict or something in the theme, any filter or action that might run during the ajax request could cause it.
Another issue that could cause this is an extremely large number of terms in the taxonomy.
You need to activate error logging and look in your php error log to find a php error. The field is populated with AJAX and you will not see error created during an AJAX request when display errors in on.
But more than likely there is a PHP error of JavaScript error causing the issue.
This would be a question for Polylang because any integration is from that plugin.
I did find this but not sure if it will help you https://polylang.pro/doc/working-with-acf-pro/#unsynchronize-the-structure
I cannot tell you how to apply this to a page template created in elementor theme builder, that would be a questions specific to elementor.
All I can tell you is how you would do this using PHP code
$current_page = get_query_var('paged', 1);
if ($current_page == 1){
// content only on first page
}
I did find this, don’t know if it will be helpful or not: https://stackoverflow.com/questions/69097872/how-to-assign-elementor-template-to-only-first-page-of-archive-category
The correct link would be
"{$domain}/{$taxonomy_slug}/{$term_slug}/feed/"
There is not URL for categories of a specific post type
But you might be able to use
/feed/?post_type=news&category_name=featured
What is the return format of your date field?
Does it match the format you are using for $today?
$today = date("m-d-Y");
$date_event = get_field('start_event');
Thanks for the information. I’ve just submitted a request asking the developers to take a look.
You are missing the 3rd argument $icon
echo wp_get_attachment_image( $image, $size, false, array ('class' => 'quick-ship' ) );
Where are you finding this
We don’t recommend outputting any ACF value without any sort of protection or escaping.
I can’t answer this question. You need to contact the developers of open a ticket on your account.
To get a list of terms you would use get_terms(). get_terms() allows a meta_query, just like WP_Query(). You can use a meta_query to get terms where a field “EXIST” or is not empty (!= “”)
see this topic https://support.advancedcustomfields.com/forums/topic/query-posts-after-today-using-acf-date/
if that does not help try one of these [FORUM SEARCH RESULTS]
I tried this below but it seems it only compares the day and not the rest of the date. If the day is a smaller number than today’s day, it does not display it..
<?php $loop = new WP_Query( array( 'post_type' => 'evenement', 'posts_per_page' => 10 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$today = date("d/m/y");
$date_event = date(get_field('start_event'));
?>
<?php if (get_field('start_event') >= $today) { ?>
<a href="<?php echo get_permalink() ?>">
<div class="image">
<?php echo the_post_thumbnail(); ?>
</div>
<div class="description">
<div class="dates">
<?php echo get_field('start_event') ?> à <?php echo get_field('hour_start_event') ?>
</div>
<div class="nom">
<?php echo the_title(); ?>
</div>
</div>
</a>
<?php }; ?>
<?php endwhile; ?>
I don’t understand why you are doing this when you are only using the selected values
$field = get_field_object(‘careguide’);
$careguide = $field[‘value’];
when you could just do this
$careguide = get_field('careguide')
But that’s neither here nor there.
You need to output an image based on the value
foreach ($careguide as $care) {
if ($care == 'some value') {
?><img srd="some image url"><?php
} elseif ($care == 'some other value') {
?><img srd="some other image url"><?php
} // .... etc
}
Or you could set the value in the checkbox field to the actual URL
radio field choices
url-1.jpg : label 1
url-2.jpg : label 2
url-3.jpg : label 3
code
foreach ($careguide as $care) {
?><img src="<?php echo $care; ?>"><?php
}
You cannot make the field readonly.
I do not have any examples, there are 2 ways that you can do this.
The first is to use custom CSS in the admin to hide the edit and delete action button for the field.
[data-key="YOU FIELD KEY"] .acf-input .link-wrap a {
display: none;
}
The second would be to add custom JavaScript to the admin to remove the action buttons instead of hiding them.
The only way to do this is with multiple meta OR queries for each related post ID
That is a very old example and what you are seeing is why I used select fields instead of ACF Post Object, Relationship or Taxonomy fields in that example. The only reason I created that repo was to post examples from work that I’ve actually done for clients.
Since I built that ACF has added the select2_ajax_data filter hook to the JS API. This filter can be used to get the value selected in another field and pass it to the server in ACF’s AJAX request used to populate the fields I mentioned above. You can then get that value from $_POST in one of the ACF server side query filters (acf/fields/relationship/query, acf/fields/post_object/query, acf/fields/taxonomy/query, acf/fields/taxonomy/wp_list_categories) to modify what is shown by ACF.
Unfortunately, I don’t have any examples of this because I have not found a reason to build them and would not rebuild old code unless it stops working.
Hey @hube2 Thanks a lot!! 🙂
It’s funny because I just found the same solution :-))
Here is what I got:
(function($) {
jQuery( document ).ready( function( $ ) {
if ( typeof acf !== 'undefined' ) {
acf.addAction('load_field', function( field ) {
if ( field.data.name === 'locations') {
const locationsField = field.$el[0];
const acfTable = locationsField.querySelector('.acf-table');
const acfTableRows = acfTable.querySelectorAll('.acf-table .acf-row');
acfTableRows.forEach((row, index) => {
const handle = row.querySelector('.acf-row-handle');
handle.classList.remove('order');
});
}
});
}
});
})(jQuery);
I will have a look at what you did as well…
I can’t give you all of the details, I can just give you some ideas. You will need to add custom JS and you will need to add an action for both the ready and append. The first is used when the page is loaded and the second will be used when a new row is added to the repeater because ACF will automatically add the class to the new row and since the row did not exist during the ready action it will not be removed.
The following is just an untested example and may need to be corrected.
In your ready action you will need to find all of the repeater rows and remove the “order” class from the handle, something like this
// the key is for the repeater
// find all rows of the repeater
// not that the selector will need to be more specific if you have nested repeater
// where you don't want to affect the nested repeter
$('[data-key="field_63597ed1ce1cb"] tr.acf-row').each(function(index, element) {
// this loops over each repeater row
// convert the element to a jQuery object
var target = $(element);
// remove the "order" class
target.removeClass('order');
}
You can do the same thing as above on the append actions, in fact you could set both the ready and append actions to the same function. However, the append action probably passes the element, but I don’t know if this is the repeater element or the row element or something else. I would likely just use the same function.
Here is an example from a project I worked on a while ago that auto generates unique ID for flexible content so that you can see what you need to do to add the JS to ACF
(function($){
if (typeof acf == 'undefined') {
return;
}
acf.add_action('ready append', function($el) {
var panel_ids = [];
$('[data-key="field_63597ed1ce1cb"] input').each(function(index, element) {
if (element.value == '' || panel_ids.indexOf(element.value) != -1) {
var new_id = acf.get_uniqid('pnl-');
element.value = new_id;
panel_ids.push(new_id);
} else {
panel_ids.push(element.value);
}
});
});
})(jQuery);
Hello John,
Thank you for your help.
For those facing this problem, here is my code:
function my_acf_prepare_field( $field ) {
$choices = $field['choices'];
asort($choices, SORT_NATURAL);
$field['choices'] = $choices;
return $field;
}
// Apply to fields named "example_field".
add_filter('acf/prepare_field/name=your_field', 'my_acf_prepare_field');
This document covers getting values from a term https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/
You are doing that incorrectly
$image_id = get_field(‘_thumbnail_id_marque’, ‘term_’ . $term_id);
you can also call this function with the term object instead of "term_{$term_id}"
This document covers using an image field https://www.advancedcustomfields.com/resources/image/
How you use it depends on what you have set as a return value for the image field. But you can always get only the ID value regardless of the return setting by setting the 3rd parameter to false
$image_id = get_field(‘_thumbnail_id_marque’, ‘term_’ . $term_id, false);
Hi,
Sorry for that misunderstanding, I’m working on woocommerce and the plugin “WP Gridbuilder”.
And a php code is exactly what I’m looking for !
So far I’ve done this :
function save_acf_image_as_featured_in_taxonomy($term_id) {
// Assurez-vous de remplacer ‘nom_du_champ_image’ par le slug de votre champ ACF
$image_id = get_field(‘_thumbnail_id_marque’, ‘taxonomy_’ . $term_id);
if ($image_id) {
// Enregistrez l’ID de l’image dans les métadonnées de la taxonomie
update_term_meta($term_id, ‘featured_image_id’, $image_id);
}
}
add_action(‘edited_ma_taxonomie’, ‘save_acf_image_as_featured_in_taxonomy’);
add_action(‘create_ma_taxonomie’, ‘save_acf_image_as_featured_in_taxonomy’);
function set_custom_card_thumbnail_for_taxonomy($object) {
// Obtenez les paramètres du grid courant.
$grid = wpgb_get_grid_settings();
// Si cela ne correspond pas à l’ID du grid 6.
if (6 !== $grid->id) {
return $object;
}
// Si l’objet est une taxonomie (ajustez ‘ma_taxonomie’ pour votre taxonomie).
if (is_a($object, ‘WP_Term’) && ‘marque’ === $object->taxonomy) {
// Obtenez l’ID de l’image ACF pour la taxonomie.
$image_id = get_field(‘_thumbnail_id_marque’, ‘taxonomy_’ . $object->term_id);
// Si un ID d’image est trouvé, affectez-le.
if (!empty($image_id)) {
$object->post_thumbnail = $image_id;
}
}
return $object;
}
add_filter(‘wp_grid_builder/grid/the_object’, ‘set_custom_card_thumbnail_for_taxonomy’);
But it’s not working…
I was poiting out the product category miniatures of woocomerce because, without any dev, it just works fine with what I’m willing to do.
Thanks.
Thanks John.
Although more complicated, on the other hand sub fields can be the same name as another field elsewhere and not clash right? So long as the sub fields inside the group field are all unique? So this provides flexibility?
First, you cannot query by the label, ACF only stores the selected value.
Second, what type of select field are you using? Can multiple choices be selected?
Look at this document for the difference between fields that can have single or multiple selections https://www.advancedcustomfields.com/resources/query-posts-custom-fields/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.