- This topic has 26 replies, 3 voices, and was last updated 1 year, 6 months ago by Jean Paiva.
-
AuthorPosts
-
September 27, 2022 at 1:08 am #2354909Matt
Are you able to provide screenshots of your setup for the site that has this working?
Based on your last commment, the fact that the dynamic population functionality uses the ‘get_post_meta’ function, means that it doesn’t use acf’s ‘get_field’ function to turn the id into a url.
September 27, 2022 at 1:17 am #2354915Fernando Customer SupportActually, that’s weird, it’s also returning the File ID from my end with
get_post_meta()
.Here’s a couple of screenshots of my setup which is working:
https://share.getcloudapp.com/o0uXPNDo
https://share.getcloudapp.com/4guel0m8
Can you try doing something like that and see how it goes?
September 27, 2022 at 7:22 am #2355277MattHmm.. I can’t seem to get this to work.
Are there any hooks I can use to programatically add the link through my child theme?
September 27, 2022 at 7:52 pm #2355875Fernando Customer SupportIn your Content Template? You can add a portable Shrotcode.
Can you first try updating to the Release versions of GenerateBlocks and GenerateBlocks Pro?: https://generateblocks.com/account/
September 27, 2022 at 8:30 pm #2355898MattHi Fernando,
I have done this and no change. I actually can’t see how getting the file URL would ever work. If GB code uses get_post_meta() function to return the meta value, and GB doesn’t have any specific intergration with ACF, then the settings I have on ACF to return a ‘array’, ‘url’ or ‘file_id’ would never be run as these are applied when using the acf get_field() function.
I mean a php hook that I can tap into and set my own link url. I can’t see how any shortcode would be useful here as I want to add the link to the outer GP container.
Thanks
September 27, 2022 at 11:28 pm #2355977Fernando Customer SupportThere’s a filter to alter the rendered block but can you try creating a field type text instead of a url, and test that instead?
September 27, 2022 at 11:29 pm #2355978MattWhat is the filter you are referring to?
September 28, 2022 at 12:15 am #2356018Fernando Customer SupportIt’s call
render_block
: https://developer.wordpress.org/reference/functions/render_block/But you’ll need to get the URL value from that field first so you can inject it as a link.
Can you try using and retrieving a text field instead to test?
September 28, 2022 at 12:23 am #2356025MattI can see that the value being returned from the file upload matches exactly what is in the post_meta table for that key (ie. 1672). So I am confident that the GB post_meta functionality is returning exactly what is in the DB and working as expected, and if I put a text value (eg. https:google.com) in there it would work as expected.
The issue is that ACF would normally retrieve the post_meta value (via the get_field() function) and then, based on the options set in the field settings, look up some other data in the DB to return and array, url or id. Unless, GB hooks into the ACF functionality (which I’m sure it doesn’t), I can’t see that this is going to work at all.
September 28, 2022 at 5:25 pm #2357010Fernando Customer SupportACF should be retrievable with
get_post_meta()
.get_post_meta()
is a core WordPress function. They just added another way –get_field
– for simplification and other data retrieving features. But the core WordPress function should work as well since it still just a post meta.See some cases here where the return value isn’t working for ACF:
Can you try #1 here to test?: https://docs.generatepress.com/article/debugging-tips/
September 28, 2022 at 5:39 pm #2357016MattHi Fernando,
I think that we agree. I don’t think this is an issue with Generatepress/ GenerateBlocks. I just don’t think what I am trying to do is possible with a ‘file upload’ type ACF meta field.
The get_post_meta() is retrieving exactly what is in the database for this post_id and key (ie. ‘file_upload’) …. which is the number ‘1672’.
The ACF get_field() function uses the get_post_meta() function to retrieve the initial value, but then evaluates the selected return format (as selected in ACF settings) and uses this to generate the requested format/value. If GP/GB doesn’t use get_fields(), then I can see why I am not getting the result I was wanting.
I’m happy to close this off now. Thanks for all of your assistance!
September 28, 2022 at 6:07 pm #2357026Jean Paiva DeveloperNext version of GB (1.6) we are adding ACF support and we are using the ACF
get_field
function.You can test the last release candidate here GenerateBlocks 1.6 RC2
-
AuthorPosts
- You must be logged in to reply to this topic.