Support

Account

Forum Replies Created

  • The latest version, 4.3.1, resolves issue for my setup. Page with issue is now rendering exactly as with ACF 4.2.2.

    My layout and loop sounds less complex than @Intervik’s. It is a single loop, which can run at most one time, and lists multiple posts containing the same set of custom fields.

    Confirmation procedure:

    1. Delete all cached versions of troublesome page. I wasted a lot of time in debugging and confirming the fix just due to resilient caching schemes.
      • Turn off all caching plug-ins.
      • Manually delete wp-content/cache directory.
      • Delete browser cache.
    2. Load page with ACF 4.2.2 -> PASS
    3. Replace ACF 4.2.2 with ACF-master from GitHub
    4. Load page with ACF-master (4.3.1) -> PASS
    5. Replace ACF-master (4.3.1) with ACF 4.3.0 from GitHub
    6. Load page with ACF 4.3.0 -> FAIL (as expected; sanity check)
    7. Replace ACF 4.3.0 with ACF 4.3.1 from WordPress plug-in page
    8. Load page with ACF 4.3.1 -> PASS


    @elliot
    , thanks for the quick turn-around on this.

    BTW, any way to append version number on WordPress hosted file, e.g. “advanced-custom-fields-4.3.1.zip”? It helps to quickly identify needed version of file and fast to archive without extra edit (and chance of label error) on user’s part.

    Peace

  • For my environment, I narrowed the issue down to the ACF core update alone (no other changes to WP and ACF add-on versions).

    Working:
    WP 3.6.1
    ACF 4.2.2
    ACF:Flexible Content Field 1.0.2
    ACF:Repeater Field 1.0.1
    ACF Repeater Collapser 1.1.0
    ACF Support for Custom Post Templates 1.0
    Custom Post Templates 1.5

    Status after updating:
    ACF 4.2.2 -> 4.3.0 :
    Page renders differently as described in earlier post. has_sub_field returning false for specified repeater field.

    Status after manual rollback:
    ACF 4.3.0 -> 4.2.2 :
    Page returns to expected rendering.

  • I searched for some keywords before reporting an issue submission and found this post.

    The OP indicates similar behavior to what I am experiencing:

    • after updating to 4.3.0 from 4.2.2 (and to latest FC and Rep add-ons from 1.0.2 and 1.0.1 respectively) a page now renders very differently. Specifically, media images stored as a sub-field in a repeater field are now showing blank due to has_sub_field function returning false semi-randomly.
    • I also came across “note: you don’t need to specify the $post_id for any sub field functions” in documentation. It appears in sample code on http://www.advancedcustomfields.com/resources/functions/has_sub_field/

    Use Case:

    1. Multiple posts created using the same ACF template.
    2. Gallery page loops through the posts to display them as a list.
    3. Every third post fails to show an image stored in the first sub-field (of two) of a repeater field.

    Code:`
    $profile_pic = get_field('profile_pic', $post_id);

    echo( “Post ID: ” . $post_id . “</br>”);
    echo( “Profile_pic repeater field: “);
    print_r($profile_pic);
    echo “</br>”;

    if (has_sub_field('profile_pic', $post_id)) {
    $attachment_id = get_sub_field('media_library_image');
    $url_link_image = get_sub_field('url_link_image');
    …`

    Debugging:
    I narrowed the issue down to the has_sub_field() call. It returns false (every third post?!) even though print_r and var_dump statements to screen and log clearly show the repeater field has a sub_field.

    *On pages where a single post is displayed, the image always shows.
    *On the page where multiple posts are queried, every third image is blank.

    After pure confusion for a few hours now, I also started to feel like the post_id is not “clearing” itself between new calls to has_sub_field.

    Temporary work-around:
    Since I know every post I am query has populated sub-fields, only solution (and risky one) is to directly access the array (e.g. $attachment_id = $profile_pic[0]["media_library_image"]; Everything shows up properly with this hack.)

    General question:
    How can I reset a call to has_sub_field so that I start again at first element of repeater field list (even if I have not reached end yet)? Sequential has_sub_field calls:`has_sub_field('profile_pic', $post_id
    has_sub_field('profile_pic', $post_id)`
    versus`has_sub_field('profile_pic', $post_id)
    has_sub_field('profile_pic', $post_id)
    has_sub_field('profile_pic', $post_id)`
    produced an ON/OFF effect.

    Environment:
    WP 3.7.1
    ACF 4.3.0

    —–
    Side note: I can understand the initial confusion OP may have with “note: you don’t need to specify the $post_id for any sub field functions” comment in documentation since has_sub_field is demonstrated both with and without use of the post_id parameter.

Viewing 3 posts - 1 through 3 (of 3 total)