[Resolved] Add Post Author with Link to About Us Page

Home Forums Support [Resolved] Add Post Author with Link to About Us Page

Home Forums Support Add Post Author with Link to About Us Page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1364967
    Connor R

    Hi there!

    I have my post meta data under the post title. It appears like the below:

    “Date | Post Category”

    I am trying to make it something like “Written by [Author Name] | Date | Post Category”

    I would also like to link the Author name to the About page. Can you give me some guidance on how I would need to modify the below PHP to make this work? Thank you!!

    add_filter( ‘generate_footer_entry_meta_items’, function() {
    return array(
    );
    } );
    add_filter( ‘generate_inside_post_meta_item_output’, function( $output, $item ) {
    if ( ‘categories’ === $item ) {
    return ‘ | ‘;
    }
    return $output;
    }, 50, 2 );
    add_filter( ‘generate_header_entry_meta_items’, function() {
    return array(
    ‘date’,
    ‘categories’,
    );
    } );

    #1364972
    Connor R

    Hi there!

    I was able to get 90% of the way there. It is now as follows:

    “by [Author] July 11, 2020 | Category”

    I am trying to change it to:

    Written by [Author] | July 11, 2020 | Category”

    In a nutshell, I am trying to change the words “by” to “Written by” and add a “|” between the author and the date.

    Thanks!

    #1365340
    David
    Staff
    Customer Support

    Hi there,

    try this PHP Snippet to change the ‘by’ to ‘Written By’:

    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"><span class="author-label">Written by </span><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
                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() )
            )
        );
    } );
    #1365864
    Connor R

    As usual, easy as pie with a little help from you! Thanks, David.

    #1366439
    David
    Staff
    Customer Support

    Glad to be of help

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