Home › Forums › ACF PRO › JSON (post_name) changes on every save › Reply To: JSON (post_name) changes on every save
Thank you for your answer John. I have been going through the default WordPress troubleshooting already, without any luck.
I narrowed it down to a filter acf/load_field/key=
which is used to fill a select dynamically. The obviously problematic part was a WP_Query
object:
function allPosts($field)
{
$field['choices'] => array();
$query = new WP_Query(array(
'post_type' => 'any',
'posts_per_page' => -1,
));
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$field['choices'][$query->post->ID] = $query->post->post_title;
}
}
return $field;
}
I substituted this with get_posts()
and now it is working again (and yes, there is a reason why I didn’t use a relationship field).
But there are still some things I’d like to understand:
a) Why should WP_Query
be a problem in this context?
b) Why didn’t this happen consistently?
c) Why should a filter be able, to break the post_name
of a field group?
Thank you.
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.