- This topic has 16 replies, 4 voices, and was last updated 1 year, 6 months ago by
David.
-
AuthorPosts
-
April 15, 2020 at 3:14 am #1239705
Brian
Hi
I need to edit my entry meta to move the comments link so that it sits on the end of the line.
I’ve searched the forum and found some code for modifying the meta, and here’s what I’m using to edit it so far.The code 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>’;
}
}And this CSS to show the comment link, plus change the post to ‘Last Updated:’
.single .comments-link {
display: inline-block;
}.posted-on .updated {
display: inline-block;
}.posted-on .updated + .entry-date {
display: none;
}.posted-on .updated:before {
content: “Last Updated: “;
}April 15, 2020 at 10:46 am #1240501Tom
Lead DeveloperLead DeveloperHi there,
Try this, instead:
add_filter( 'generate_header_entry_meta_items', function( $items ) { $items[] = 'comments-link'; return $items; } );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 15, 2020 at 10:49 am #1240507Brian
Still the same π
April 15, 2020 at 1:33 pm #1240665Brian
Hi Tom,
I changed the snippet to that code, but that it seems to eliminate the comment link altogether.April 15, 2020 at 5:24 pm #1240825Tom
Lead DeveloperLead DeveloperIs the comments count option enabled in Customize > Layout > Blog?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 16, 2020 at 1:47 am #1241127Brian
No, it wasn’t. I enabled it and the comment link now works now.
I thought that was just to show the link on archives which I’m not sure I want, but I can live with.
Thanks for the help Tom πApril 16, 2020 at 8:58 am #1241782Tom
Lead DeveloperLead DeveloperYou could try this:
body:not(.single) .comments-link { display: none; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 16, 2020 at 9:22 am #1241839Brian
Hey Tom
That worked, thanks so much!April 16, 2020 at 3:40 pm #1242208Tom
Lead DeveloperLead DeveloperYou’re welcome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 2, 2020 at 3:34 am #1514207Brian
Hi Tom
The code to show a comment link seems to have stopped working, here’s what I have in place.
Snippet
add_filter( 'generate_header_entry_meta_items', function( $items ) { $items[] = 'comments-link'; return $items; } ); add_filter( 'generate_post_date_output', function( $output, $time_string ) { printf( '<span class="posted-on">%s</span> ', $time_string ); }, 10, 2 );
CSS
.single .comments-link { display: inline-block; } .posted-on .updated { display: inline-block; } .posted-on .updated + .entry-date { display: none; } .posted-on .updated:before { content: "Last Updated: "; } body:not(.single) .comments-link { display: none; }
November 2, 2020 at 9:58 am #1514936Leo
StaffCustomer SupportAny chance you can link us to the page/post in question?
The link in the original topic is no longer working.
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/November 3, 2020 at 2:45 am #1515753Brian
Hi Leo, here’s a link
https://www.savvyhomemade.com/bath-bomb-recipe/November 3, 2020 at 10:55 am #1516608Tom
Lead DeveloperLead DeveloperHi there,
Try adding this:
add_action( 'wp', function() { if ( is_single() ) { add_filter( 'generate_show_comments', '__return_true' ); } } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 4, 2020 at 1:04 am #1517233Brian
Hi Tom
That worked, thanks!
Any idea how to style it to separate it from the author’s name, perhaps with a verticle bar before?by Author | 29 Comments | This post contains affiliate links,
Brian
November 4, 2020 at 2:54 am #1517356David
StaffCustomer SupportHi there,
add this CSS:
.entry-meta .comments-link:before { content: '| '; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.