• gspowart

    (@gspowart)


    I noticed this error when I tried to update from 0.8.8.9 to the next version and have left it for a few versions to see if would be fixed but it’s still an issue for me now.

    We have an Advanced Link field which is within a Repeater which is itself within Flexible Content. It was working fine but on updating the plugin, if I do get_field then the array looks like this (i.e. it’s pretty much empty) and therefore doesn’t display properly on the front end.

    Array ( [type] => post [value] => 8 [url] => [name] => [title] => Download the Case Study [target] => )

    Strangely it doesn’t affect every single instance (I think it might be different whether it’s linking to a Post or URL) and also, saving the page can retrieve some of the values.

    Any thoughts? We’re staying on the older version of the plugin for now.

    Thanks, Gregor

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    In your get_field() value example:

    Array(
    [type] => post
    [value] => 8
    [url] => (this is generated with get_the_title())
    [name] => (this is generated with get_permalink())
    [title] => Download the Case Study
    [target] =>
    )

    It looks like the Post ID: 8 you selected in your Advanced Link Field doesn’t exist anymore (that post was probably deleted). This is why the name and url are empty, because these are generated by ACF Extended based on the post ID, with get_the_title() and get_permalink().

    This is also the reason why the issue seems to only affect certain pages and not others. Because other Advanced Link fields probably have a valid post selection.

    I would recommend to check that the url key is not empty before displaying the link in the front-end, so you’re sure you got a valid element to display.

    Note these name and url keys are automatically added when the value is formatted. They don’t exist if you get the raw value from the database.

    With format = false as last argument in your get_field('my_advanced_link', false, false) (see documentation), you’ll only retrieve what is actually saved in the database. In your case it would be:

    Array(
    [type] => post
    [value] => 8
    [title] => Download the Case Study
    [target] =>
    )

    But the issue will be the same, your selected post still doesn’t exist, so you cannot retrieve information like the permalink anymore.

    You can check the value that is saved in the database using the Developer Mode (see documentation). This module will display a metabox on each post in the admin, with all WP & ACF metadata saved on them.

    Here is an example of the database value using the Developer Mode with an Advanced Link field inside a Flexible Content > Repeater setup similar to yours: See screenshot.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter gspowart

    (@gspowart)

    Hi, thanks for the reply. I don’t think what you’re describing is the issue so I’ve taken a few screenshots to try to illustrate what I’m seeing.

    This is the field as seen in the editor with version 0.8.8.9 – https://drive.google.com/file/d/1yoifpOINkL2igB3mjmITa73Ytq3HCyRM/view?usp=sharing

    And this is what’s shown in the Developer mode for this field – https://drive.google.com/file/d/1ytH9jw7_1qk-wbSKOYfBCiipUCEnb78Q/view?usp=sharing

    Outputting get_sub_field(‘cta_button’) results in this:

    Array ( [title] => Download the report [url] => https://<domain>/about-us/resources/ibm-cost-of-a-data-breach-report-2024/ [target] => 0 )

    If I then update ACF Extended to the latest version 0.9.0.7 and don’t do anything else except refresh the edit page, then the field looks like this – https://drive.google.com/file/d/1yqy9u5B4R6LiMdoOv2y_s6ssFwgQRK1z/view?usp=sharing

    Developer mode looks like this (unchanged from before)- https://drive.google.com/file/d/1ykrtVSmUVhYJpCmAjwGvXfj6u7EeF4gD/view?usp=sharing

    Outputting get_sub_field(‘cta_button’) results in this:

    Array ( [type] => url [value] => 8 [url] => 8 [name] => 8 [title] => Download the report [target] => )

    Obviously the URL field isn’t populated so the link doesn’t display on the front end.

    In this case it’s not pointing to a particular post ID, it’s just pointing to a URL so it’s not a case of the Post ID not existing. Note that there are other links on the same page which are pointing to posts but it’s the same issue – the array isn’t populated correctly. For example, here are two outputs from get_sub_field() on the old version-

    Array ( [title] => Read the case study [url] => https://<domain>/about-us/case-studies/maidstone-tunbridge-wells-nhs-trust-power-bi/ [target] => 0 )
    Array ( [title] => Download our PDF [url] => https://<domain>/wp-content/uploads/2020/01/Northdoor_DWWP_210112.pdf [target] => 0 )

    And here they are after the plugin has been updated and the page refreshed (note that nothing has been changed on the page and it hasn’t been saved again – it’s just a plugin update) –

    Array ( [type] => url [value] => 8 [url] => 8 [name] => 8 [title] => Read the case study [target] => )
    Array ( [type] => url [value] => 8 [url] => 8 [name] => 8 [title] => Download our PDF [target] => )

    I hope this helps. Apologies if I’ve misunderstood anything. It’s worth noting that this is an Advanced Link within a repeater which is within a flexible content field, so perhaps that adds a bit of complexity.

    Thanks, Gregor

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the additional details.

    Please allow me some time to do some tests, and try to reproduce the issue with the data you provided. I’ll come back to you soon.

    Thank you for your patience.

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.