Site logo

Archived topic

Link post author dynamic link to a static page

3 replies · Started by Carl on February 22, 2022

Viewing posts 1–4 of 4

I started with Dispatch from the site library, and I am trying to make what I think might be a minor modification.

In the Single Post Hero element, I am trying to link the author name field to the site About page /about/ instead of to the author archive page /author/authorname

Is this possible? I've been going through all the documentation and options for 'Dynamic link type'

TIA. <3 GP.

Hi Carl,

If you have GenerateBlocks Pro, you can place the specific Headline Block inside a Container Block and set a link to the Container.

See: https://share.getcloudapp.com/yAuk5pG8

Also see: https://share.getcloudapp.com/JruGrKdE

Otherwise, you would need custom code to achieve this. Here is a sample PHP code.

add_filter( 'generate_dynamic_element_url', function( $url, $link_type, $source, $block ){
	if ( '44c1ba07' === $block['attrs']['uniqueId'] ) {
		$url = 'https://google.com';
	}
	return $url;
},15,4);

Kindly replace the uniqueId(44c1ba07) with the ID of your Block, and the url link to your preferred link.

See: https://share.getcloudapp.com/WnuqjLXg

Here is an article you may refer to regarding adding PHP: https://docs.generatepress.com/article/adding-php/

If you’re not comfortable with adding/using custom codes, I suggest using GenerateBlocks or hiring a developer because wrongly implemented code may break your site.

Hope this helps! :)

Hi Fernando, I just added that php via code snippets and it worked perfectly!

Thank you for your help.

You’re welcome Carl! Glad to be of assistance! Feel free to reach out anytime if you’ll need assistance with anything else. :)

This archived topic is closed to new replies.