Site logo

Archived topic

Post Meta Author Name Customization & Linking it to a custom page

1 reply · Started by Pritam on June 12, 2021

Viewing posts 1–2 of 2

I have modified the last updated meta filed by following this tutorial:
https://generatepress.com/forums/topic/display-original-date-and-last-update-date/

Currently, it's showing like this: https://imgur.com/O0i2GjY

But the author name is not linked to the default author page.
How to do that? Also tell me how I can link the author name to a custom page ex, domain.com/meet-the-team.

One more thing: how to add "written by" before the author name.

This is the Php code I am using for showing the User Avatar.

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">%4$s<span class="author-name" itemprop="name">%3$s</span></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() ),
            get_avatar( get_the_author_meta( 'ID' ) )
        )
    );
} );

And this is the php code, I am using for showing the last updated date:

add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';

    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
        $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on %4$s</time>';
    }

    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )
    );

    return sprintf( '<span class="posted-on">%s</span> ',
        $time_string
    );
}, 10, 2 );

This is the CSS:

.byline img {
   width: 40px;
    height: 40px;
    border-radius: 50%;
    position: relative;
    vertical-align: middle;
    margin: 0 10px 0 0;
}

.entry-date {
    order: -1;
    margin-right: 10px;
    border-right: 1px solid #ddd;
    padding-right: 10px;
}
This archived topic is closed to new replies.