Archived topic
Add Post Author with Link to About Us Page
4 replies · Started by Connor R on July 15, 2020
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',
);
} );
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!
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() )
)
);
} );
As usual, easy as pie with a little help from you! Thanks, David.
Glad to be of help