Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Issue with ACF File URL Rendering in GenerateBlocks

  • Hello and a happy New Year!

    I’m using ACF to create a custom post type with a file upload field where the return value is set to ‘File URL’. In my content template element, I’m using a couple of GenerateBlocks (v1.9.1) headers, with the dynamic data configured to pull the relevant post meta value.

    However, on the rendered page, the link displays the file ID instead of the file URL. I also tried adding a button with the same settings, but it also renders only the file ID.

    What’s confusing is that I’ve compared all the settings against another site I built using GenerateBlocks Pro, where this functionality works perfectly.

    Based on David’s suggestion, I tested the GB 2.0 alpha release, but unfortunately, the issue persists.

    Many thanks!
    Will

  • Hi there,

    in the ACF Field – can you confirm that eturn format is set to URL ? Just double checking as that really should work out the box.

    If its not, could i get an admin login to take a look ?

  • Hi David,

    Thanks for taking a look. Staging server details below.

  • Sorry, forgot to add that yes, both ACF fields have a return value of ‘File URL’.

  • Hi there,

    You are still using v1 block, you need to disable the Use version 1 blocks option at settings >generateblocks > settings.

  • Hello and thanks for your follow-up.

    I’ve disabled the version 1 blocks option as suggested, but unfortunately, this hasn’t resolved the issue with my existing links.

    I also added a new container using just GB 2 blocks to test further and observed the following:

    When attempting to add the post meta file link to a GB Headline block titled ‘Lesson Plan’, I found that it doesn’t allow me to set custom anchor text. Instead, the options are limited to selecting from Post, Author, and Media tags.

    I then tried using a button block, which does allow me to separate the label from the dynamic link. However, the link generated is not the file URL but instead points to an address like 0.0.1.23.

    If it helps, I’ve left this test work on the page I shared in my private message.

  • The ACF Field is returning the attachment ID – which the browser is converting to a IP address.

    Try the following:

    1. set the ACF field to return the Array.
    2. in your Block add your dynamic tag but after the key add .url so the key would be my_field_name.url

  • Thanks for your suggestion. I’ve updated the ACF file field (lesson_plan) to return a file array and adjusted the button link to {{post_meta key:lesson_plan.url}}.

    Unfortunately, this hasn’t resolved the issue, and the link still displays as the converted IP address.

    It’s quite puzzling since I have an identical setup working perfectly on another site that uses GB Pro. Do you know if there’s any difference between the standard GenerateBlocks and GB Pro in how meta values are handled?

    Appreciate your insights on this!

  • Hello again,

    Following up, I’ve set up a fresh WordPress installation on my local machine using LocalWP to test this issue further. Here’s the configuration and steps I’ve taken:

    Setup Details:

    WordPress (clean install)
    Theme: GeneratePress (v3.5.1)
    Plugins Installed:
    GP Premium (v2.5.0)
    GenerateBlocks (v1.9.1)
    ACF (v6.3.11)

    Steps Taken:

    Created a custom post type called Modules.
    Added a field group called File Test, with a file field named lesson_plan.
    Set up a GP Content Template element.
    In the template, added:
    A GB Headline block (dynamic content set to the title).
    A GP dynamic content block.
    Another GB Headline block, with dynamic data set to:
    Link Source: Post Meta
    Post Meta Field: lesson_plan
    Link Type: Default

    Results:

    On the front end, the content displays as expected, except the field link only shows the file ID (e.g., http://file-test.local/module/link-test/12) rather than the file URL.

    I’ve also tested by changing the ACF file field return value to File Array or File ID, but this makes no difference—only the file ID is displayed.

    Am I missing something, or is there a potential issue with how the dynamic data handles file URLs in this setup?

    Looking forward to your thoughts.

  • Are you using GB 1.9.1? Can you update it to 2.0 and use the new dynamic tag system?

  • Hi Ying and David,

    Thanks for getting back to me.

    I had already upgraded and tested GenerateBlocks to version 2.0 on the staging site I shared, but unfortunately, no luck. I’ve also updated my local development environment and still see the file ID being outputted as a URL.

    As I mentioned earlier, the only site where this is working is running GenerateBlocks Pro 1.7.1. After cross-checking the database, I see that ACF stores the file ID in both cases. Since everything else — WordPress version, PHP version — is identical, I can only assume there’s a difference in how the GB Pro and WordPress.org versions handle the ACF file fields.

    Regarding version 2.0, I’m not sure if I’ve misunderstood the setup process for a post meta button link, or if there’s an issue with this version as well. Either way, it’s rendering the file ID which is getting translated to a URL.

    Unfortunately, time’s not on my side, so I’ll need to move away from pursuing a nicely integrated solution and look at creating shortcodes to manage this instead.

    Thanks for your assistance — I appreciate your help!

  • I see the issue, you will need GB Pro to display the URL if the field type is file.

    If you only have the free version, you need to use URL type field instead of file type field.

  • Hi Ying,

    Thanks for confirming. Just upgraded to the GeneratePress One subscription and all’s fine and dandy!

  • Great! Glad to hear that 🙂

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