Site logo

[Support request] ACF Page link in dynamic elements

Home Forums Support [Support request] ACF Page link in dynamic elements

Home Forums Support ACF Page link in dynamic elements

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2122171
    Andrew

    Heya. I can’t seem to get ACF Page Link fields working in dynamic blocks in an Element.
    If I set a standard text field I can get a Headline and Button linking by entering the Page URL but this is a not very user friendly. Is there any reason this would not return a page URL as per a basic text field? Thanks.

    https://www.advancedcustomfields.com/resources/page-link/

    #2122192
    Elvin
    Staff
    Customer Support

    Hi Andrew,

    There’s a known bug that may be related to this.

    See Tom’s workaround here – https://generatepress.com/forums/topic/container-dynamic-link-adds-invalid-link/#post-2095258

    It requires a bit of PHP, here’s how to add it on your site – https://docs.generatepress.com/article/adding-php/

    Let us know if you need clarification. 😀

    #2122199
    Andrew

    Thanks Elvin. That filter relates to Container links. Do I need a different filter for a button?

    *edit: FYI It’s a CPT and custom taxonomy but not sure if that’s relevant. Working site is here:
    https://valleyseeds.com.au/varieties/lucerne/

    #2122204
    Elvin
    Staff
    Customer Support

    Ah yes that’s right. For the button you’ll need the generate_dynamic_element_url.

    Can you specify which button has the issue? So I can check for clues as to what exactly is happening to it.

    To be sure if the issue is w/ how or what format the link is being returned as by ACF. 🙂

    #2123423
    Andrew

    For some reason it’s outputting the page ID, not the URL.
    https://valleyseeds.com.au/varieties/deep-rooted-perennial/
    If I output the value in a dynamic Headline text block it returns the post ID, not the URL. If I try and add it as a button link it just returns the current url.

    I can’t work it out – the ACF function should be returning the url as per the documentation
    https://www.advancedcustomfields.com/resources/page-link/

    I might just try and render this button out using a shortcode.

    #2123624
    Elvin
    Staff
    Customer Support

    I might just try and render this button out using a shortcode.

    That can work. But to solve the issue directly, we can continue with the debug.

    Can you do a var_dump() of this page’s meta? particularly, the key used for page link?

    Something like var_dump(get_post_meta(get_the_ID(),'key_of_page_link',false)); and have it displayed on the front-end so we can analyze it.

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