Site logo

[Resolved] Add rel=”author” to dynamic data

Home Forums Support [Resolved] Add rel=”author” to dynamic data

Home Forums Support Add rel=”author” to dynamic data

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2532404
    Trey

    I am using Headline dynamic data to display the author name and link to the author archives in my content template block element for my posts. I would like to include rel=”author” in the a href to the author archives. Please let me know how I can achieve this.

    Thanks

    #2532417
    Fernando
    Customer Support

    Hi Trey,

    Try adding add-author-rel to the class list of the Block.

    Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/

    Then, add this snippet:

    function db_rerender_link( $block_content, $block ) {
    	if(!is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'add-author-rel' ) !== false  ) {
    			$my_search='href="';
    			$my_replace='rel="author" href="';
    			$new_content = str_replace($my_search, $my_replace, $block_content);
    			return $new_content;
    	}
        return $block_content;
    }
     
    add_filter( 'render_block', 'db_rerender_link', 10, 2 );

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    #2532421
    Trey

    That worked like a charm! Thanks Fernando

    #2532429
    Fernando
    Customer Support

    You’re welcome, Trey!

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