ACF Relationship Field giving error when added more than one post
-
Hey all,
I was actually sent over here from by
I’ve been beating my head against this issue for the last day and have not been able to track down what is causing this issue.
So, right now I have a custom post type I created called “gallery_slides” that we are using to make individual slides for a bootstrap carousel gallery.
I have created two separate ACF blocks:
- One to use with the “gallery slides” custom post type visual editor. This uses ACF fields to add whatever content to the slide you would want.
- Another to use an ACF relationship field to display whatever slides you want in the carouse gallery.
Everything is working fine for the CPT portion so far. The gallery slides are being saved correctly and I can write them all to a page using WP_Query without any issues.
The problem comes into play when I try the add “gallery slides” using the ACF Relationship field in the block designed to render them to a page. When I add the first one, everything seems fine, when I add a second one from the relationship list, it immediately breaks the block, giving this error:
“This block has encountered an error and cannot be previewed.”
When I check the console, it’s also giving me a “TypeError: e is null, jQuery 5, onAppend…” error. When I click on the post.php link to see where the error occurred, it just says “originalMethod(…args);” If I remove the WP_Query and just try to var_dump the relationship field with a foreach() it still does the same thing.
If I save and refresh the page, the “gallery slides” I chose have been correctly saved, but if I change anything within the relationship field it breaks again. If I preview it, the “gallery slides” are being correctly rendered on the front end.
I have two other custom post types that are being used the same way and they work perfectly fine with the relationship field. They take the relationship field as a variable and run it through a foreach() that does a WP_Query for each one selected.
Does anyone have any idea what might be causing this? I feel like it’s something simple that I overlooking, so any help would be greatly appreciated.
Link to error screenshots: https://drive.google.com/drive/folders/1WQf7glsw0r_8Ove2EciQrwlrKUdWFKTF?usp=drive_link
- The topic ‘ACF Relationship Field giving error when added more than one post’ is closed to new replies.