- This topic has 4 replies, 2 voices, and was last updated 3 years, 4 months ago by
Tom.
-
AuthorPosts
-
September 27, 2019 at 6:54 pm #1020989
Jose
Hello, I would like my byline to look like the example in https://docs.generatepress.com/article/entry-meta-style/#example-1
but without the “leave a comment”.
https://pasteboard.co/IzqJaJH.pngUsing code from:
https://docs.generatepress.com/article/entry-meta-style/#example-1
https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-dateI get this – Name is linked : (blue highlight = link) –
https://pasteboard.co/IzqJJd2.pngWhen I add:
https://docs.generatepress.com/article/generate_post_author_output/#remove-link
I get this:
https://pasteboard.co/IzqMOdf.pngCurrent Code:
// CREATE UPDATED DATE FUNCTION SHORTCODE - TEMP DISABLED// /* function post_modified_date() { return get_the_modified_date(); } add_shortcode( 'modified_date', 'post_modified_date' ); // */ // Entry Meta Style Example 1 // https://docs.generatepress.com/article/entry-meta-style/#example-1 // 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', 'comments-link', 'date', ); } ); // //Remove Link from Author // https://docs.generatepress.com/article/generate_post_author_output/#remove-link // add_filter( 'generate_post_author_output', function() { printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>', __( 'by','generatepress'), 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() ) ) ); } ); // // Remove Link from Date - ENABLED // https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date // add_filter( 'generate_post_date_output', function( $output, $time_string ) { printf( '<span class="posted-on">%s</span>', $time_string ); }, 10, 2 ); //
Thanks so much!
September 28, 2019 at 9:37 am #1021360Tom
Lead DeveloperLead DeveloperHi there,
Instead of using both filters (which overwrite each other), we can combine them into one function:
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">%2$s<span class="author-name" itemprop="name">%1$s</span></span>', esc_html( get_the_author() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } );
Let me know if that helps or not ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 29, 2019 at 2:23 am #1021670Jose
Thanks for your prompt response!
No more links, but it’s out of order.
https://pasteboard.co/IzD8bg1.png// September 28, 2019 at 9:37 am #1021360 SUPPORT 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">%2$s<span class="author-name" itemprop="name">%1$s</span></span>', esc_html( get_the_author() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); // Remove Link from Date - ENABLED // //https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date // add_filter( 'generate_post_date_output', function( $output, $time_string ) { printf( '<span class="posted-on">%s</span>', $time_string ); }, 10, 2 );
September 29, 2019 at 2:46 am #1021681Jose
Ah! Just needed to add the 2nd add_filter from – Entry Meta Style Example 1 – https://docs.generatepress.com/article/entry-meta-style/#example-1.
add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'comments-link', 'date', ); } );
Thanks!
Just a quick follow up question…
Does the “Leave a Comment” not appear because I have WordPress comments disabled or is it part of the code?
Full Code:
// SUPPORT CODE //https://generatepress.com/forums/topic/entry-meta-style-example-1-removing-all-links-no-leave-a-comment/#post-1021360// + 2nd Part of Entry Meta Style Example 1 - https://docs.generatepress.com/article/entry-meta-style/#example-1 // 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">%2$s<span class="author-name" itemprop="name">%1$s</span></span>', esc_html( get_the_author() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); } ); // Plus 2nd Part of Entry Meta Style Example 1 - https://docs.generatepress.com/article/entry-meta-style/#example-1 // add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'comments-link', 'date', ); } ); // Remove Link from Date - ENABLED // //https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date // add_filter( 'generate_post_date_output', function( $output, $time_string ) { printf( '<span class="posted-on">%s</span>', $time_string ); }, 10, 2 ); //
September 29, 2019 at 9:10 am #1021965Tom
Lead DeveloperLead DeveloperThe comments link won’t show up if:
1. You’re on a single post
2. Comments are turned offLet me know if you need more info ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.