Archived topic
how to add last updated and author name with gravator without plugin
1 reply · Started by Sanu Kumar on January 6, 2020
how to add last updated and author name with gravatar without a plugin.
Currently, I am using this PHP:
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' ) )
)
);
} );
add_filter( 'generate_header_entry_meta_items', function() {
return array(
'author',
'comments-link',
'date',
);
} );
add_filter( 'generate_footer_entry_meta_items', function( $items ) {
return array(
'date',
'categories',
);
} );
I have added this code in code snippets plugin...but I want to know is there any other method without plugin..If so, then could you tell me, because I don't want more plugin on my site.
Thanks
Hi there,
Code snippets really shouldn't slow down your site at all - it's simply a way for you to add code.
You can do a speed test with and without Code Snippets to see if there are any effects at all.
The other option is to use a child theme:
https://docs.generatepress.com/article/adding-php/#use-a-child-theme