- This topic has 7 replies, 2 voices, and was last updated 4 years, 3 months ago by
Tom.
-
AuthorPosts
-
February 13, 2019 at 3:18 am #809078
Jasmina
Hi,
I tried to disable the author link and the date / modified date on single post and archives. (not the text, just want to disable links)
I am using this code to style the meta post data: https://docs.generatepress.com/article/entry-meta-style/
1. problem: the arrangement of the post meta on single posts is different to the post meta on archives.
arrangement on single post: author | modified date | comment count
arrangement on archive pages: author | comment count | modified date > Like here:How can I arrange it in the same way on every single post AND archive pages?
2. problem: when I additionally use your snippets for disbaling the author link and date link, the link is still clickable or a second line with a date is added.
how can I solve this problem?
Thanks
JasminaFebruary 13, 2019 at 8:46 am #809499Tom
Lead DeveloperLead DeveloperHi there,
So the main difference is the comment count? Would you like to add it to the single posts, or remove it from the archives?
You’ll need to disable the links inside the same function you’re using to re-order them. Any chance you can share your function and I can tweak it for you?
Let me know π
February 14, 2019 at 2:16 am #810055Jasmina
Hi Tom,
I reordered the meta data with these two snippets:
add_filter( 'generate_post_author', '__return_false' ); add_filter( 'generate_show_comments', '__return_false' ); add_filter( 'generate_post_date_output', 'tu_fancy_byline' ); function tu_fancy_byline( $date ) { printf( ' <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' ) ) ) ); if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo '<span class="comments-link">'; comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); echo '</span>'; } echo $date; }
Second Snippet:
add_filter( 'generate_post_date_output', 'lh_single_comments_link' ); function lh_single_comments_link( $date ) { echo $date; if ( is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo '<span class="comments-link">'; comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); echo '</span>'; } }
Now my target is to disable the author-link and the date-link in the meta data – shown in single post and on archive pages.
Thanks a lot
JasminaFebruary 14, 2019 at 9:28 am #810568Tom
Lead DeveloperLead DeveloperHi there,
Try this as your function (and remove the second one):
add_filter( 'generate_post_author', '__return_false' ); add_filter( 'generate_show_comments', '__return_false' ); add_filter( 'generate_post_date_output', 'tu_fancy_byline', 10, 2 ); function tu_fancy_byline( $date, $time_string ) { printf( ' <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' ) ) ) ); if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo '<span class="comments-link">'; comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) ); echo '</span>'; } printf( '<span class="posted-on">%s</span>', $time_string ); }
February 15, 2019 at 12:14 am #811001Jasmina
Thanks a lot, Tom! π Copied your function an removed the 2nd one.
Now IΒ΄m just missing the “Comments”-Part in meta data on single posts. Take a look – there are just author + date > example https://www.seniorpfoten.de/nasenbluten-hund/
February 15, 2019 at 9:10 am #811432Tom
Lead DeveloperLead DeveloperI just edited the function above: https://generatepress.com/forums/topic/disable-author-date-link-on-entry-meta-in-single-post-archive-pages/#post-810568
Let me know if it does the trick π
February 18, 2019 at 1:18 am #813292Jasmina
Great! π It works
Excellent support!
Tanks a lotFebruary 18, 2019 at 9:16 am #813706Tom
Lead DeveloperLead DeveloperYou’re welcome π
-
AuthorPosts
- You must be logged in to reply to this topic.