Check that the “project_galleries” field in ACF is set up as a REPEATER, and inside it, “project_gallery” is configured as a gallery.
To work with Gutenberg blocks, you can try using the “get_field()” function instead of “have_rows()”. Try this:
<?php
$galleries = get_field('project_galleries');
if($galleries):
foreach($galleries as $gallery):
$images = $gallery['project_gallery'];
if($images):
foreach($images as $image): ?>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<p><?php echo $image['caption']; ?></p>
<?php endforeach;
endif;
endforeach;
endif; ?>
This worked for me. Be sure to set your Google Maps API key beforehand if you have not done so already.
replace “pickup_” with your custom field keys.
/**
* Save Google Map field data to custom fields in ACF
*
* This snippet hooks into the ACF save process to extract the data
* from a Google Map field and save it to custom fields for address,
* city, state, zip code, latitude, and longitude.
*
* @param int $post_id The ID of the post being saved.
*/
function save_google_map_data_to_custom_fields($post_id) {
// Check if this is an autosave or if the user has permission to save
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// Check user permissions
if (!current_user_can('edit_post', $post_id)) {
return;
}
// Get the Google Map field value
$google_map_data = get_field('your_google_map_field_name', $post_id);
// Check if the Google Map field has data
if ($google_map_data && is_array($google_map_data)) {
// Extract data from the Google Map field
$street_number = isset($google_map_data['street_number']) ? $google_map_data['street_number'] : '';
$street_name = isset($google_map_data['street_name']) ? $google_map_data['street_name'] : '';
$city = isset($google_map_data['city']) ? $google_map_data['city'] : '';
$state = isset($google_map_data['state']) ? $google_map_data['state'] : '';
$post_code = isset($google_map_data['post_code']) ? $google_map_data['post_code'] : '';
$country = isset($google_map_data['country']) ? $google_map_data['country'] : '';
$latitude = isset($google_map_data['lat']) ? $google_map_data['lat'] : '';
$longitude = isset($google_map_data['lng']) ? $google_map_data['lng'] : '';
// Save to custom fields
update_field('pickup_address', trim("$street_number $street_name"), $post_id);
update_field('pickup_city', $city, $post_id);
update_field('pickup_state', $state, $post_id);
update_field('pickup_zipcode', $post_code, $post_id);
update_field('pickup_country', $country, $post_id); // If you want to save the country as well
update_field('pickup_latitude', $latitude, $post_id);
update_field('pickup_longitude', $longitude, $post_id);
}
}
// Hook into ACF save process
add_action('acf/save_post', 'save_google_map_data_to_custom_fields');
I have found a solution to this if anyone is interested.
When using renderTemplate ACF renders the template and then replaces <InnerBlocks /> with the actual rendered blocks after the fact.
However, if you use renderCallback instead the second argument of the callback is the fully rendered inner blocks and therefore this would work:
function my_render_callback($block, $content, $is_preview=false) {
if($is_preview) {
echo "<InnerBlocks />"; // render JSX in the editor
}
else {
$has_inner_blocks = strnlen($content) > 0;
if($has_inner_blocks) {
echo $content;
}
}
}
<div class="social_icons">
<?php
if( have_rows('social_icons', 'option') ):
while ( have_rows('social_icons', 'option') ) : the_row(); ?>
<a href="<?php the_sub_field('link'); ?>" title="<?php the_sub_field('name'); ?>"> <?php the_sub_field('font_awesome_code'); ?> </a>
<?ph endwhile;
else :
endif;
?>
</div><!-- .social_icons -->
This fixed it which means I was wrong in my assumptions above. I just basically overwrote the existing locations array and everything works fine:
add_filter( 'acf/validate_field_group', 'add_custom_location_dynamic', 10, 1 );
function add_custom_location_dynamic( $field_group ) {
if ( $field_group['key'] === 'group_6786e0728946a' ) {
// This line below clears any existing locations
$field_group['location'] = array();
$currentYear = get_field('current_year', 'option');
$awardArgs = createYearArray($currentYear);
// $awardArgs is just an array of ["2024", "2025"]
$x=0;
foreach($awardArgs as $year) {
$field_group['location'][$x][] = array(
'param' => 'post_type',
'operator' => '==',
'value' => 'entrant_'.$year,
);
$x++;
}
}
return ($field_group);
}
Hope that helps anyone else looking for this.
Same request,
Is there some hook or filter we can use to add our own icons.
Would be nice to add our own tab then pass an array of [key => url_path_string].
Hola, pudiste solucionarlo? me pasó lo mismo y no se que mas hacer para recuperar el sitio
Same issue here, after a bit of inspecting it appears that this is only affecting radio buttons for me at the moment and only on some sites across various different WP versions, no multisite and latest ACF version.
Any newly duplicated blocks inherit the copied block settings but the settings in the original block are removed when doing this.
I’m not sure if this is the actual issue or intended behaviour but the additional fields inside the block are all inheriting the same data-block-id value. Block ID’s are all still unique though.
<div class=”acf-block-fields acf-fields” data-block-id=”block_b2d072f5-ef0d-48ad-92c7-6e3ad9a30fd0″>
Great solution! If you’re dealing with custom post types and PDF downloads, using plugins like Contact Form 7 or WPForms can help you easily manage form submissions and provide users with a unique PDF link after submission. It’s a smooth way to manage content distribution. By the way, if you’re also looking for sustainable packaging options, check out Bee Printers
Why are you using functions to enqueue the style, use the JSON style decalaration. Or try putting the wp_enqueue_style call into the template. It’s also not clear to me why you’re using a function to call the template rather than a JSON declaration.
Other than that (these should work anyway), check that the CSS file exists by interrogating the src parameter.
I find the easist way to do this is to set up most of the code (and test it with a string literal) and then use ACF to load the unique part (ID, verfication code etc)
If you can get your iframe working hard-coded then swap out the changing parts for variables generated from CF fields
Apologies for resurrecting an old thread, but I am still seeing this error on:
– WordPress 6.7
– ACF Pro 6.3.11
– Firefox 132.0.2 (both Windows 10 and macOS)
I am testing on a fresh install of WordPress using the stock Twenty Twenty-five theme with only ACF Pro enabled. I created a single field group with a single WYSIWYG field.
When opening the editor, the field appears to load normally, but after refreshing the field does not show any content and becomes unresponsive to any input in the main editor area, although I am able to click on the buttons in the TinyMCE toolbar as well as the Visual/Test toggle.
There are no errors in the Firefox console, only the following which appear to be warnings:
Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. markup.js:250:53
This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. post.php
JQMIGRATE: Migrate is installed, version 3.4.1 load-scripts.php:5:981
downloadable font: Glyph bbox was incorrect (glyph ids 11 19 20 21 55 58 79 96 101 115 116 120) (font-family: "tinymce" style:normal weight:400 stretch:100 src index:1) source: http://acf-wysiwyg-issue-test.local/wp-includes/js/tinymce/skins/lightgray/fonts/tinymce.woff
Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. ce917c4a-18c0-4680-a2b9-2d1ec833f72d
MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead. block-editor.min.js:21:494336
MouseEvent.mozInputSource is deprecated. Use PointerEvent.pointerType instead. block-editor.min.js:21:494336
MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead. tinymce.min.js:2:8857
MouseEvent.mozInputSource is deprecated. Use PointerEvent.pointerType instead. tinymce.min.js:2:8857
Great! Thank you very much. Grabbed the code and adjusted to me need where i only want to query one option. In case someone needs it as well:
add_action("rest_api_init", function () {
register_rest_route("options", "/clients", [
"methods" => "GET",
"callback" => "acf_options_route",
]);
});
function acf_options_route() {
return get_field('lmdm_clients','option');
}
lmdm_clients is a repeater field in this case…
Someone on StackOverflow helped me out! This is the answer
<?php
$terms = get_the_terms(get_the_ID(), 'locatie'); // Get the terms associated with the post
if ($terms && !is_wp_error($terms)) :
foreach ($terms as $term) : ?>
<h2><?php echo esc_html($term->name); ?></h2>
<p><?php echo esc_html($term->description); ?></p>
<?php endforeach;
endif;
?>
I found I had the same issue even without the Classic Editor installed. Here is a very hack-y workaround that fixed it for my project. Not a great solution, though, and may affect the layout in unexpected ways, but it does not require direct editing of any plugin source code.
https://github.com/dylansouthard/wp-safari-render-fix
I should’ve just opened a support ticket in the first place! Got a quick response from the ACF team this morning that the issue is because I have WP_DEBUG
and SCRIPT_DEBUG
turned on, since I’m running this on a dev site. Turning those off should resolve the issue, and apparently the ACF team does have a fix for this issue ready to go prior to the official WP 6.7 release.
Same issue here!
Saving checkboxes inside of a group is not working properly. Outside of it works correctly.
Reproducable Steps:
0. Create CPT
1. Create Fieldgroup
2. Create a Group field
3. Create a Checkbox field with some options inside the Group
4. Create a Post within the CPT
5. Check some options of the Checkbox field in the post editor
6. Save and reload the page
This will result into having no checked indication in any of them.
It will be correctly queryable though. It seems to be registered in the database but there is no visual feedback in the post editor.
Khám phá cảm giác hồi hộp của n666, cánh cổng dẫn đến thế giới trò chơi trực tuyến đầy phấn khích. Với bộ sưu tập trò chơi phong phú, từ trải nghiệm Casino đến cá cược thể thao, bắn cá, đá gà và nổ hũ, chúng tôi đáp ứng mọi mong muốn giải trí. Hãy tham gia cùng chúng tôi ngay để khám phá các sự kiện hấp dẫn và nhận phần thưởng độc quyền!
@pattyok I wasn’t seeing the error on a clean WP install with no other plugins, so I re-added other plugins one by one and found that WPGraphQL for ACF was actually triggering the bug for me. I will give your code a try, as it would be nice to be able to have both plugins activated and still be able to edit custom fields. Thanks for your quick reply!
The issue had come and gone, but has resurfaced again with the latest version of ACF Pro (6.3.8) so I was just revisiting today.
It appears that they have wrapped the localization script for a value (isLicenseActive) that is used by addProLocations in an if (is_admin()) script. (acf-pro.php line 127) So it is not available on the front end causing that js error.
Adding the following to your js enqueue function seems to solve the problem. I am also going to open a bug on the issue.
$to_localize = array(
'isLicenseActive' => acf_pro_is_license_active(),
'isLicenseExpired' => acf_pro_is_license_expired(),
);
acf_localize_data( $to_localize );
You can find useful information on other WordPress solutions on this site.
Thanks for the spam!
That data structure is the PHP Serialize format, you can use it as is, or decode/encode it using unserialize()
and serialize()
. as long as your destination field is the same type then the data is just an array of two items, “value” and “label”.
This is how ACF packs multiple pieces of information into a single db cell when it makes sense for some field types, the equivalent would be JSON encoding.
Did You managed that to work properly?
Cause I’ve got similar problem with my blocks, much simpler code:
<?php
// Create class attribute allowing for custom "className" and "align" values.
$class_name = 'my-block';
if ( ! empty( $block['className'] ) ) {
$class_name .= ' ' . $block['className'];
}
if ( ! empty( $block['align'] ) ) {
$class_name .= ' align' . $block['align'];
}
if ( ! empty( $block['alignText'] ) ) {
$class_name .= ' text-align-' . $block['alignText'];
}
$anchor = '';
if ( ! empty( $block['anchor'] ) ) {
$anchor = 'id="' . esc_attr( $block['anchor'] ) . '" ';
}
$custom_id = wp_unique_id( 'custom-' );
$attrs = $is_preview ? 'class="'.$class_name.'"' : get_block_wrapper_attributes(
[
'class' => $class_name
]
);
?>
<section <?php echo $anchor; ?> <?php echo $attrs; ?>>
<!-- my block content -->
</section><!-- /.full-section -->
In admin panel my SECTION is wrapped with extra div, on frontend everything is fine.
I’ve got problem with double classes in frontend too, when I remove this code:
$class_name .= ' ' . $block['className'];
it’s better, but in admin panel it’s a little pain in ass.
I ended up doing a workaround by downgrading like you did, but I can totally relate to the frustration. The fix you shared with the custom script looks solid! I’ve found some quick wins for my own projects just by combining ACF tweaks with small SEO adjustments.
And so this is possible via block.json’s
"data": {
"variable": "A"
},
"providesContext": {
"acf/fields": "data"
},
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.