- This topic has 17 replies, 4 voices, and was last updated 4 years, 2 months ago by
Tom.
-
AuthorPosts
-
January 24, 2022 at 4:20 pm #2092371
Shane
when trying to create a container with a dynamic link and acf field, a link is created but the value is
#, as it just adds that to the url value field.

The link href value on the frontend is
#.Any idea why?
January 24, 2022 at 4:54 pm #2092388Elvin
StaffCustomer SupportHi Shane,
For this specific single post, can you try doing a var_dump() for this particular custom field?
To know if the link_url field is returning a value. If it doesn’t return a value, can you check the post’s link_url field if it has a url in it? can you also verify if the custom field handle is correct?
Let us know. 😀
January 25, 2022 at 10:15 am #2093398Shane
Hello!
Using
get_field('link_url')on the page does return the value.January 25, 2022 at 10:57 am #2093450Shane
Just to add some more context…
I’m having this issue with a Container module which lives inside of a Left Sidebar Element. That sidebar is inserted into a Custom Post Type. So the ACF field that I’m trying to pull in lives on the CPT object.
January 25, 2022 at 12:48 pm #2093558Ying
StaffCustomer SupportHi Shane,
If you add this dynamic link to a headline block, does the link work?
January 25, 2022 at 12:48 pm #2093559Shane
Yes it does, just not the container
January 25, 2022 at 1:09 pm #2093590Ying
StaffCustomer SupportCan you link us to the page where we can see the issue?
January 25, 2022 at 1:25 pm #2093605Shane
Added via private message
January 25, 2022 at 3:20 pm #2093696Ying
StaffCustomer SupportHum..it does look like a bug to me, we will look into it.
For now, can you try replace one of the
headlineblock (eg.software ->)in the container with abuttonsblock, and add the dynamic link to thebuttonsblock.Then add this CSS to make the container clickable:
.gb-container.guide-sidebar-cta a:before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .gb-container.guide-sidebar-cta { position: relative; }January 25, 2022 at 7:25 pm #2093800Shane
Hello, that’s done.
Also, when using the page link ACF field, the return value is an ID of the selected post link. Is this a bug?
January 25, 2022 at 9:07 pm #2093831Elvin
StaffCustomer SupportHi Shane,
ACF fields of specific types have an option to return an ARRAY, ID or a single value. You may have to check and verify if this particular field has the preferred value(it should be single).
January 26, 2022 at 10:23 am #2094786Shane
Hi, just want to clarify that the button solution didn’t work, as using ACF’s page_link field, which doesn’t have an option to select a single value or id, only outputs the ID of the selected post. Also tried Link type and that doesn’t output a value at all.
January 26, 2022 at 1:37 pm #2094958Shane
Okay this works when ACF is a text field, but doesn’t work when it’s a link page and a field.
Seems like this is a hack workaround, but is there anyway to look into the bug so the container can work as expected?
January 26, 2022 at 10:02 pm #2095258Tom
Lead DeveloperLead DeveloperHi there,
This is a confirmed bug where the custom field value doesn’t work in Container links. It will be fixed in the next GPP update.
For now, you can do something like this:
add_filter( 'generateblocks_attr_container-link', function( $attributes, $settings ) { $link_type = ! empty( $settings['gpDynamicLinkType'] ) ? $settings['gpDynamicLinkType'] : ''; if ( $link_type && '' !== $settings['url'] && ( 'wrapper' === $settings['linkType'] || 'hidden-link' === $settings['linkType'] ) ) { $id = get_the_ID(); if ( ! $id ) { return $attributes; } if ( 'post-meta' === $link_type ) { if ( ! empty( $settings['gpDynamicLinkCustomField'] ) ) { $custom_field = get_post_meta( $id, $settings['gpDynamicLinkCustomField'], true ); if ( $custom_field ) { $attributes['href'] = esc_url( $custom_field ); } } } } return $attributes; }, 20, 2 );That should fix the bug. If the ACF field isn’t working, we may need to see what kind of value to expect. If that’s the case, replace this:
$custom_field = get_post_meta( $id, $settings['gpDynamicLinkCustomField'], true );With this:
$custom_field = get_post_meta( $id, $settings['gpDynamicLinkCustomField'], true ); var_dump($custom_field);And let us know what kind of debug code shows on the frontend with the posts.
Thanks!
January 27, 2022 at 1:48 pm #2096397Shane
Hello!
I updated the container and content with how it was previously, and also added the snippet of code you provided.It seems to work.
I changed the ACF field to page link and the value that outputs is the selected page ID.
I also tested this with
get_field()and the output is a url. -
AuthorPosts
- You must be logged in to reply to this topic.