Site logo

Archived topic

Add #top to dynamic links

7 replies · Started by Anders Nielsen on January 28, 2023

Viewing posts 1–8 of 8

Hi there

I'm using the dynamic data in generateblocks..

Is there a hack or something I can do to add a #top to the post links?

See video in private section

Hi Anders,

1. Try using the Dynamic data option in the editor's sidebar instead of the option from the floating bar.

2. Try adding a CSS class to that headline block of the link, eg. anchor-link,

3. Add this PHP snippet:

add_filter('generateblocks_dynamic_url_output','add_html_anchor_to_dynamic_link', 10,2);
function add_html_anchor_to_dynamic_link($url , $attributes) {
	if( ! empty( $url ) && ! empty( $attributes['className'] ) &&  'anchor-link'  === $attributes['className'] )  {
		$url = $url.'/#top'; 
	}
	return $url;
}

Brilliant @ying

It is working perfect :)

Awesome :)

Is there any way I can add a "before text" like the option in the floating bar

You can use another headline block before the link, and set both headline block toinline-wdith.

Thx :)

No Problem :)

This archived topic is closed to new replies.