Site logo

Archived topic

Custom author link

3 replies · Started by Gianluca on September 10, 2020

Viewing posts 1–4 of 4

Hi,

I'm currently using this snippet https://docs.generatepress.com/article/entry-meta-style/#example-1 and css to style the entry meta like the example (without the "leave a comment" section).

However I'd like to add a custom author link to the author's name as showed here https://docs.generatepress.com/article/generate_post_author_output/#custom-author-name

Is it possible to combine the 2 snippets to achieve the current layout https://imgur.com/a/YwwhVuF and add a custom link on my name?

Thank you

Hi there,

is there a single author ? Or will there be multiple authors?

If its a single author then you can change the first filter snippet to this:

add_filter( 'generate_post_author_output', function() {
    return sprintf( ' <span class="byline">%1$s</span>',
        sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%3$s<a href="your_custom_url_goes_here" title="%1$s" rel="author"><span class="author-name" itemprop="name">%2$s</span></a></span>',
            esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
            esc_html( get_the_author() ),
            get_avatar( get_the_author_meta( 'ID' ) )
        )
    );
} );

Note this part of the above code is where you add your custom URL:

<a href="your_custom_url_goes_here"

Thank you David!

You're welcome

This archived topic is closed to new replies.