- This topic has 23 replies, 4 voices, and was last updated 2 years, 3 months ago by Elvin.
-
AuthorPosts
-
June 30, 2020 at 3:50 am #1346739Ravi Saive
I want to show all meta tags in one line in single post article only with below order:
Avatar – Author Name | Last Updated Date | Categories | Comments
Please see the image for your reference: https://ibb.co/rtYdC74
June 30, 2020 at 8:03 am #1347147DavidStaffCustomer SupportHi there,
use this example here:
https://docs.generatepress.com/article/entry-meta-style/#example-1
just update this part of the PHP from:
add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'comments-link', 'date', ); } );
to:
add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'categories', 'comments-link', ); } );
June 30, 2020 at 10:56 am #1347343Ravi SaiveIn which file I need to update…
June 30, 2020 at 2:44 pm #1347523TomLead DeveloperLead DeveloperThis would be added using one of these methods:
This would be your complete code:
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<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() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'categories', 'comments-link', ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { return array_diff( $items, [ 'categories', 'comments-link' ] ); } );
Then you’d also need to add the CSS listed on the page David linked you to. That CSS can be added using one of these methods: https://docs.generatepress.com/article/adding-css/
Hope this helps!
June 30, 2020 at 11:54 pm #1347771Ravi SaiveThanks, David and Tom,
The given code working fine now…
I have a few more settings do like I want to display tags and next-previous navigation like the one in this screenshot: https://ibb.co/X7bFV8d
July 1, 2020 at 12:49 am #1347808Ravi SaiveAlso, I have one issue…
I have created a hook for Related Posts and added CSS to child theme style.css file, but the CSS is not working, but the same CSS working if I add in Customize Additional CSS section.
July 1, 2020 at 4:13 am #1347969DavidStaffCustomer SupportHi there,
could you create new separate topics for those request. This one can then be marked as resolved.
July 3, 2020 at 2:55 am #1350322Ravi SaiveHi David and Tom,
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<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() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'categories', 'comments-link', ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { return array_diff( $items, [ 'categories', 'comments-link' ] ); } );
The above code is working great, but I just want to remove the author image only from the above code.
July 3, 2020 at 9:58 am #1350859TomLead DeveloperLead DeveloperThis is it without the 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"><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() ) ) ); } ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'categories', 'comments-link', ); } ); add_filter( 'generate_footer_entry_meta_items', function( $items ) { return array_diff( $items, [ 'categories', 'comments-link' ] ); } );
July 3, 2020 at 8:46 pm #1351243Ravi SaiveHi Tom,
Thanks, it worked, great support and great theme ๐
July 4, 2020 at 9:17 am #1351852TomLead DeveloperLead DeveloperThanks! ๐
January 5, 2022 at 2:21 am #2069661Ravi SaiveHi David and Tom,
I have updated the GP theme to Version: 3.1.0 and the above code is not working…
Before update – https://ibb.co/Jz6rYk1
After update – https://ibb.co/5Y6Y3Nv
Total comments count not showing after update..
January 5, 2022 at 3:45 am #2069739DavidStaffCustomer SupportHi there,
can you share a link to a post where i can see the issue ?
January 5, 2022 at 11:23 pm #2070781Ravi SaiveHi David,
I am testing on a staging server, so can’t be possible to give access, but you can check the Live site at:
Live site – https://ibb.co/478YXkb [Where total comments count showing]
Staging Site – https://ibb.co/pxwW8tQ [where total comments count not showing]
January 5, 2022 at 11:43 pm #2070786ElvinStaffCustomer SupportHi there,
Can you tell us how you’ve added the PHP snippet?
If you’ve placed the snippet inside the theme’s functions.php, it would make sense why the changes applied prior to the update were removed because updating the theme overrides the edited functions.php with a fresh functions.php from 3.1.
Here’s how you should be adding the PHP snippet so it’s unaffected by theme updates –
https://docs.generatepress.com/article/adding-php/ -
AuthorPosts
- You must be logged in to reply to this topic.