Home › Forums › Front-end Issues › Front-end relationship field not loading posts unless searched for
I have several front end fields all working perfectly. The only one I’m having a bit of trouble with is the relationship field. It doesn’t actually load the posts unless I search for a specific post – the wheel just keeps spinning.
I’m outputting it in the following way. Is there a way I can list all the posts properly as per the backend?
<?php $activity_information = array( 'post_id' => $post->ID, // post id to get field groups from and save data to 'field_groups' => array(169), // this will find the field groups for this post (post ID's of the acf post objects) 'form_attributes' => array( // attributes will be added to the form element 'class' => '' ), 'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url 'html_field_open' => '<div>', // field wrapper open 'html_field_close' => '</div>', // field wrapper close 'html_before_fields' => '', // html inside form before fields 'html_after_fields' => '', // html inside form after fields 'submit_value' => 'Update', // value for submit field 'updated_message' => '', // default updated message. Can be false to show no message ); acf_form( $activity_information ); ?>
I’m not sure why this is happening, but a good start will be to check your console log. You should see the AJAX call (in firebug) and can determin what the returned data is.
Perhaps you will find that the returned data is empty. In this case, can you turn on DEBUG MODE and try again, this will hopefully show a PHP error in the returned AJAX data
Any progress on this issue?
I’m having exactly the same problem. I’ve got a really simple setup as per the instructions here: http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/
Just pulling all the fields as is from a particular field group.
The form is working perfectly except for the relationship field group. The wheel just keeps spinning and nothing loads in the box.
If I change the field type to “Post Object” it loads the values perfectly.
Looks like a problem with the AJAX loading in the front-end form. In the backend add/edit post form, the same relationship field works perfectly.
Thanks for the info, but can you please follow my previous comment and look in your console log for the AJAX data error?
I had the same issue and it was because I was running with DEBUG set to true. There was an error in another plugin causing an alert stopping the rest of the script from running. setting DEBUG back to false got everything running again.
Same issue. Fixed by noticing that when switching domains in wpengine, the wordpress settings domain didn’t change, which is used by ACF to make the ajax request.
The topic ‘Front-end relationship field not loading posts unless searched for’ is closed to new replies.
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.