@bisonbrah & @cosystudios
The latest version 2.1.2 fixes the Block ‘block-name’ can’t be inserted
issue!
https://github.com/Log1x/acf-composer/releases/tag/v2.1.2
@bisonbrah No I’m afraid not…
I don’t see any console errors in the admin and I don’t see any PHP error logs.
Just the toast message:
Block "Block Name" can't be inserted.
It happens on blocks where I have $parent
defined as:
public $parent = [];
but also on blocks where I haven’t defined $parent
at all?
See topic: https://github.com/Log1x/acf-composer/issues/340
Hi @cosystudios,
Yes indeed, I can confirm I’m having the same Block X can't be inserted
error now…
Haden’t noticed that yet.
Thanks @joshf, I can confirm this fixed the issue for me!
I would like to update acf-composer to 3.4.3+ to fix these no support for this block type issues, however I can’t since I then also need to upgrade Acorn v2 to v3 and that’s not an option for me right now since it’s an older theme.
Therefore I need to stay on acf-composer 2.1. Is there no other way to fix this? I don’t have $parent
defined in any of my acf blocks?
I can’t upgrade to wordpress 6.8 because of this?
One of the blocks that doesn’t get registered anymore has the following attributes:
public $supports = [
'align' => false,
'align_text' => false,
'align_content' => false,
'anchor' => false,
'mode' => true,
'multiple' => true,
'jsx' => true
];
And fails on this line in plugins/advanced-custom-fields-pro/assets/build/js/pro/acf-pro-blocks.min.js?ver=6.4.0.1
with error Cannot read properties of undefined (reading 'attributes')
:
return u.attributes.anchor && (u.attributes.anchor = {
type: "string"
}),
Yes, I’ve got the same error!
This happens on ACF blocks where the (core) anchor
attribute is not even set?
Downgrading to WordPress 6.7.2 is the only way to fix it.
Yep, that did the trick!
Thanks!
Thanks @lgladdy!
I will try this asap, sounds logical 🙂
This is still an issue in 2020. I’m using the Gravityforms User Registration add-on to create users and populate acf fields with form data. In the backend on the user profile all the fieldvalues are there, the metafields are also present in the database.
But the fields won’t show up in the WP Rest API or with get_field, unless I manually save the user profile…
What should we do to make the fieldvalues available right away?
Thanks!
Ah duh! This line messed it up:
'key' => 'field_' . uniqid()
This is different on every page load…
Is there a best practice on how many characters this key should be?
Sorry, not related in the end. Saving works now!
Not sure if this is the same problem I’m experiencing, but fields that I defined using the acf_add_local_field
function are also not saving on my custom post types?
I’m running:
Gutenberg editor is disabled.
Ok thanks for your reply!
I thought I could use the acf_add_local_field
instead for this, so I added the following action that displays my checkboxes correctly now:
add_action('acf/init', array(&$this, 'addServiceMatchMakerFilter'));
public function addServiceMatchMakerFilter() {
if (function_exists('acf_add_local_field')) {
$posts = new Posts();
$global = $posts->getGlobalInfo();
$questions = $global['match_maker_questions'];
// Add field for each match maker question
if (!empty($questions)) {
foreach ($questions as $question) {
$choices = [];
if (!empty($question['choices'])) {
foreach ($question['choices'] as $choice) {
$value = $choice['choice_value'] ? $choice['choice_value'] : $choice['choice_label'];
$choices[$value] = $choice['choice_label'];
}
}
acf_add_local_field([
'key' => 'field_' . uniqid(),
'label' => $question['label'],
'name' => sanitize_title($question['label']),
'type' => 'checkbox',
'parent' => 'field_5d3ebbd2fef0c',
'choices' => $choices,
//'layout' => 'horizontal',
]);
}
}
}
}
However, when saving my post the values from these fields are empty again (also in frontend). Any idea why this is happening?
Thanks, Toine
Good catch! Thanks!
Did you ever figure this out? I want to achieve exactly the same!
Right now, I have the following setup (I used item & collection to match your example);
In my post type I have the following rewrite set:
'rewrite' => array('slug' => 'item/%collection%'),
And a function that replaces %collection% for the acf value:
function setupItemPermalink($post_link, $id = 0) {
$post = get_post($id);
if (is_object($post) && get_post_type($post) == 'item') {
$collection = get_field('item_collection', $post->ID);
if ($collection) {
$collection = get_post($collection[0]); // get first in array
return str_replace('%collection%' , $collection->post_name, $post_link);
} else {
$other = sanitize_title(__('not-in-collection', 'mydomain'));
return str_replace('%collection%' , $other, $post_link);
}
}
return $post_link;
}
add_filter('post_type_link', 'setupItemPermalink', 1, 3);
This part works! When I use the_permalink for an item, it outputs:
http://www.mydomain.com/item/collection-name/item-slug/
But I’m not sure how I should setup my rewrites?
This is not working:
global $wp_rewrite;
$item_structure = '/item/%collection%/%item%/';
$wp_rewrite->add_rewrite_tag('%item%', '([^/]+)', 'item=');
$wp_rewrite->add_permastruct('item', $item_structure, false);
Any ideas?
+1
As a workaround, it would be great to have an option to choose the output as HEX or RGB. That way, you can at least use it in CSS to add the opacity.
Sorry, I spoke too soon…
I think the query itself works, but the post order is all messed up.
The posts with both start and end date are in between the posts with only a start date in the wrong order.
Wow thanks, that works perfectly!
I ended up doing this:
/* Ongoing Past Events */
$ongoing = new WP_Query( array(
'post_type' => 'event',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'acf_event_date_start',
'value' => date('Ymd'),
'compare' => '<',
'type' => 'date'
),
array(
'key' => 'acf_event_date_end',
'value' => date('Ymd'),
'compare' => '>=',
'type' => 'date'
)
),
'orderby' => 'meta_value_num',
'order' => 'DESC'
));
if ($ongoing->have_posts()) :
$exclude = array();
while($ongoing->have_posts()) : $ongoing->the_post();
$exclude[] = $post->ID;
endwhile;
endif;
/* Past Events */
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query( array(
'post_type' => 'event',
'post__not_in' => $exclude, // Exclude ongoing past events
'meta_query' => array(
array(
'key' => 'acf_event_date_start',
'value' => date('Ymd'),
'compare' => '<',
'type' => 'date'
)
),
'orderby' => 'meta_value_num',
'order' => 'DESC',
'paged' => $paged
));
Which also works, but you need 2 queries which is not ideal.
Thanks for your help!
A year has passed, nobody interested in this feature?
@John Huebner:
Thanks for your code! This works great, however there were 2 minor syntax errors in your code. Updated code:
function post_updating_callback( $post_id ) {
$repeater = 'page_sections'; // the field name of the repeater field
$subfield1 = 'page_section_title'; // the field I want to get
$subfield2 = 'page_section_slug'; // the field I want to set
// get the number of rows in the repeater
$count = intval(get_post_meta($post_id, $repeater, true));
// loop through the rows
for ($i=0; $i<$count; $i++) {
$get_field = $repeater.'_'.$i.'_'.$subfield1;
$set_field = $repeater.'_'.$i.'_'.$subfield2;
$value = get_post_meta($post_id, $get_field, true);
$new_value = sanitize_title($value);
update_post_meta($post_id, $set_field, $new_value);
}
}
add_action('acf/save_post', 'post_updating_callback', 20);
Thanks a lot!
I got this working by enqueuing some jQuery in my functions.php:
https://github.com/scribu/wp-posts-to-posts/issues/469
This appears to be a serious bug, rolling back to version 5.1 seems to work too.
Same here!
After updating to ACF Pro 5.1.1, have_rows('repeater_field_name')
returns true even with no rows in the repeater/flexible content field. This is a serious bug…
Had to roll back to 5.1.
Thanks Elliot!
I can confirm the fix works!
Any word on an update with proper fix?
I don’t know, are we supposed to report the bug somewhere or are the developers reading the support forums too?
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.