Site logo

Archived topic

linking author in post to about page

5 replies · Started by dassana on March 26, 2019

Viewing posts 1–6 of 6

hi

from each post, i would like to link my name to the about page. currently i am using this code and it removes the linking of the author url. please let me know how i do i add about page url to my name on the post.

add_filter( 'generate_post_author_output','tu_no_author_link' );
function tu_no_author_link() {
    printf( ' <span class="byline">%1$s</span>',
        sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>',
            __( 'by','generatepress'),
            esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
            esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
            esc_html( get_the_author() )
        )
    );

    if ( is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
        echo ' | <span class="comments-link">';
            comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
        echo '</span>';
    }
}

Hi there,

Try this:

add_filter( 'generate_post_author_output','tu_no_author_link' );
function tu_no_author_link() {
    printf( ' <span class="byline">%1$s</span>',
        sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <a href="%5$s"><span class="fn n author-name" itemprop="name">%4$s</span></a></span>',
            __( 'by','generatepress'),
            esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
            esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
            esc_html( get_the_author() ),
            'URL TO YOUR ABOUT PAGE HERE'
        )
    );

    if ( is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
        echo ' | <span class="comments-link">';
            comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
        echo '</span>';
    }
}

thank you tom. the code worked very well. if i have to add a no follow tag to the about page link, then what should i modify in the code. thanks again.

In the code, find this:

<a href="%5$s">

And replace it with:

<a href="%5$s" rel="nofollow">

thank you tom. the code worked. thanks again.

You're welcome :)

This archived topic is closed to new replies.