// Generate author image and link in separate containers

add_filter( 'generate_post_author_output', function() {

    return sprintf( ' <div class="author vcard">%4$s</div><div class="author-wrap"><span class="label">Written by</span><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></div>',

            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' ) )

    );

} );


// Filter meta items to display date and author

add_filter( 'generate_header_entry_meta_items', function() {

    return array(

        'author',

        'date',

        'social-icons',

    );

} );


// Filter post date to display latest date

add_filter( 'generate_post_date_output', function( $output, $time_string ) {

    $time_string = '<span class="label">Last updated: </span><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 = '<span class="label">Last updated</span><time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%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( '<div class="posted-on">%s</div> ',

        $time_string

    );

}, 10, 2 );