Home › Forums › Support › How we can set post meta (Author name | Comment Count | Last Updated Date) ?
- This topic has 7 replies, 2 voices, and was last updated 4 years ago by Leo.
-
AuthorPosts
-
March 26, 2020 at 5:29 am #1210563Akash
How we can set post meta (Author name | Comment Count | Last Updated Date). I also show reference image for more details. Please share code without plugin how we can setup in single post and archive post.
Image Link: https://prnt.sc/rn5ip7
March 26, 2020 at 11:43 am #1211101LeoStaffCustomer SupportHi there,
Would this be for both blog listing page and single post?
March 27, 2020 at 2:03 am #1211578AkashYes, blog listing page and single post
March 27, 2020 at 9:04 am #1212161LeoStaffCustomer SupportHi there,
Add this PHP snippet:
add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'comments-link', 'date', ); } ); add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) { if ( '' === $item ) { return ''; } if ( 'comments-link' === $item ) { return ' | '; } if ( 'date' === $item ) { return ' | '; } return $output; }, 50, 2 );
Adding PHP: https://docs.generatepress.com/article/adding-php/
And this CSS to start:
.single .comments-link { display: inline-block; }
Adding PHP: https://docs.generatepress.com/article/adding-php/
March 28, 2020 at 12:49 am #1212696AkashThanks for help LEO,
I have some question:
1) How we can remove by before author name
2) How we can add vertical bar after comment (see attached image for more details)Image 1: https://prnt.sc/ro8p6j
3) How we can remove comment count below excerpt in blog listing page (see attached image for more details)
Image 2: https://prnt.sc/ro8pyk
March 28, 2020 at 10:38 am #1213264LeoStaffCustomer Support1) Edit the PHP above:
https://generatepress.com/forums/topic/how-we-can-set-post-meta-author-name-comment-count-last-updated-date/#post-12121612) How are you adding the last updated date currently? Can you link me to the page in question?
3) You’d need this filter:
https://docs.generatepress.com/article/generate_footer_entry_meta_items/April 11, 2020 at 1:56 am #1234849AkashHi LEO
2) How are you adding the last updated date currently? Can you link me to the page in question?
I am using Last modified date using this code: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 );
how we can show vertical bar before last maodified date.
3) How we can remove meta in blog archive footer.
For more information see image: https://prnt.sc/rx8blmApril 11, 2020 at 11:44 am #1235524LeoStaffCustomer SupportAny chance you can link us to the site in question?
You can edit the original topic and use the private URL field.
Let me know 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.