Home Forums Bug Reports Bug ACF 5.2.0 – Custom Fields stop rendering


Bug ACF 5.2.0 – Custom Fields stop rendering

  • After updating from 5.1.8 to 5.2.0, my custom fields stopped rendering.

    Did you change the way 5.2.0 sets/gets the field data? Because get_fields() didn’t return anything.

    To temporarily fix this issue, I reverted ACF back to 5.1.8.

    Also – is this the kind of thing you would prefer in the Help Desk? or is this still a Bug Report issue?


  • Hi @jgraup

    There is a known issue where field groups are not appearing on the post edit screen. Is this what you are experiencing?

    I have just released 5.2.1 to fix this.

    No changes have been made to get_fields, can you update and test the issue and report back with more detail regarding this?


  • Do you have a link to 5.2.1? My update in WP is only showing 5.2.0.

  • Ignore that, I just used my original download link and I see 5.2.1. I’ll report back soon.

  • Same problem. Looks like it’s specific to Post Object fields. While they are set in the edit screen, get_fields/get_field is returning null values.

  • Hi @jgraup

    perhaps this is a different issue to what I thought. Can you elaborate more on the issue? Perhaps include some code which is not working and also explain where you are using the code.


  • For example, I have a custom post type that displays a video. That video is also a custom post type with custom fields. In order to associate the video with the post, I have a field called ‘video’ that is a Post Object. That way, I can just pick the video in a list to display on that post.

    When I upgraded the plugin, the videos just stops showing up. When I revert the plugin, they work again. Actually, anything using a Post Object field – which there are quite a bit (Sliders, featured items…).

    With 5.1.8 this will return a Post Object:

    $post = get_post(60);
    echo $post->post_title;
    $fields = get_fields(60);
    $video_post_object = $fields['video'];
    $field = get_field('video', 60);
    print_r($video_post_object); // WP_Post Object ( [ID] => 926 ... )

    In 5.2.X the video field is blank/null/whatever.

    Field Name: video
    Field Type: Post Object
    Required: No
    Filter by Post Type: Video
    Filter by Taxonomy: –
    Allow Null? No
    Select Multiple? No
    Return Format: Post Object
    Conditional Logic: No

    Video is one example, but all Post Objects return null with get_field/get_fields.

    I should also note, the field groups are currently being setup in the admin section under the Custom Fields tab – so ACF is driving all of this.

  • post_object.php line 170
    $groups = acf_get_grouped_posts( $args );
    $groups = acf_get_posts( $args );

    get_posts( $value ) is removed

    render_field()/format_value() uses $this->get_posts


    render_field()/format_value() uses acf_get_posts

    Not sure if it makes a diff, but it looks like in your 5.2.1|acf_get_posts() you loop the product of $posts=get_posts, while in 5.1.8|$this->get_posts() you loop the $value and don’t deal with the product of get_posts.

  • Hi @jgraup

    Sorry, but I am finding it dificult to understand the issue.

    Can you clearly explain what CTP and Fields you have and how they are connected?

    You say that $video_post_object is blank? But you also show an array of objects as your debug result…


  • Sorry, I realize this may be confusing.

    Data is displayed on the front-end until I replace the plugin with 5.2.1.

    At that time my Post Object fields only output null.

    Consider any debug info you see coming from 5.1.8.

  • Hi @jgraup

    Can you provide me with login details and the ability to modify theme / plugin files?
    I’ll happily do some debugging as I can’t confirm this issue locally.

  • Sorry Elliot, and thank-you for your support, but I’d rather not cross the whole NDA jazz just yet.

    If I’m the only one experiencing the problem then I’ll just hold off upgrading.

    When I do, I’ll try to do some more debugging to see what is getting saved and how it’s getting pulled out. Clearly something has changed in your api w/acf_get_grouped_posts & acf_get_posts in regards to the PostObject field.

    I’ll keep you posted if anything changes.

  • Hi @jgraup

    Perhaps your theme / plugin contains some pre_get_posts filters which are modifying ACF’s get_posts function?

    There has been a minor change to the acf_get_posts function in that it does not use get_post anymore, instead it only uses get_posts.

    This could explain how a filter may be altering the query args and preventing the correct data from being returned.

  • I think that sounds very likely. I’ll explore that idea first and let you know if I find anything.

  • I removed any reference to pre_get_posts the best I could. I’ve made my theme able to drop the multilingual plugin I have activated for testing and I believe I found the issue.

    ACF 5.2.X is not compatible with PolyLang Version 1.7.2.

    Check out polylang/frontend/frontend-auto-translate.php; PLL_Frontend_Auto_Translate->pre_get_posts($query);

  • [LONGSHOT…] Here is the file that may be causing the problem. Do you see any quick fixes at first glance?

  • Hi @jgraup

    Yes, the function contains a loop which would run when the posts__in arg is supplied (this is used by ACF):

    // array of post ids
    137	                // post_parent__in & post_parent__not_in since WP 3.6
    138	                foreach (array('post__in', 'post__not_in', 'post_parent__in', 'post_parent__not_in') as $key) {
    139	                        $arr = array();
    140	                        if (!empty($qv[$key])) {
    141	                                // post__in used by the 2 functions below
    142	                                // useless to filter them as output is already in the right language and would result in performance loss
    143	                                foreach (debug_backtrace() as $trace)
    144	                                        if (in_array($trace['function'], array('wp_nav_menu', 'gallery_shortcode')))
    145	                                                return;
    147	                                foreach ($qv[$key] as $p)
    148	                                        $arr[] = ($tr = pll_get_post($p)) ? $tr : $p;
    150	                                $qv[$key] = $arr;
    151	                        }
    152	                }

    I’m not sure what the code does exactly, but it looks to modify the id’s.

    I would advise that you debug this function by printing out the $qv varible before and after this loop. This will show what has changed:


  • Great! Thanks Elliot, I’ll give that a try.

  • This reply has been marked as private.
Viewing 19 posts - 1 through 19 (of 19 total)

The topic ‘Bug ACF 5.2.0 – Custom Fields stop rendering’ is closed to new replies.