[Resolved] linking author in post to about page

Home Forums Support [Resolved] linking author in post to about page

Home Forums Support linking author in post to about page

  • This topic has 5 replies, 2 voices, and was last updated 5 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #850601
    dassana

    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>';
        }
    }
    #850848
    Tom
    Lead Developer
    Lead Developer

    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>';
        }
    }
    #851185
    dassana

    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.

    #851571
    Tom
    Lead Developer
    Lead Developer

    In the code, find this:

    <a href="%5$s">

    And replace it with:

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

    #852219
    dassana

    thank you tom. the code worked. thanks again.

    #852628
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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