- This topic has 16 replies, 4 voices, and was last updated 3 years, 5 months ago by David.
-
AuthorPosts
-
April 15, 2020 at 3:14 am #1239705Brian
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 #1240501TomLead DeveloperLead DeveloperHi there,
Try this, instead:
add_filter( 'generate_header_entry_meta_items', function( $items ) { $items[] = 'comments-link'; return $items; } );
Let me know π
April 15, 2020 at 10:49 am #1240507BrianStill the same π
April 15, 2020 at 1:33 pm #1240665BrianHi 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 #1240825TomLead DeveloperLead DeveloperIs the comments count option enabled in Customize > Layout > Blog?
April 16, 2020 at 1:47 am #1241127BrianNo, 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 #1241782TomLead DeveloperLead DeveloperYou could try this:
body:not(.single) .comments-link { display: none; }
April 16, 2020 at 9:22 am #1241839BrianHey Tom
That worked, thanks so much!April 16, 2020 at 3:40 pm #1242208TomLead DeveloperLead DeveloperYou’re welcome π
November 2, 2020 at 3:34 am #1514207BrianHi 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 #1514936LeoStaffCustomer 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 π
November 3, 2020 at 2:45 am #1515753BrianHi Leo, here’s a link
https://www.savvyhomemade.com/bath-bomb-recipe/November 3, 2020 at 10:55 am #1516608TomLead DeveloperLead DeveloperHi there,
Try adding this:
add_action( 'wp', function() { if ( is_single() ) { add_filter( 'generate_show_comments', '__return_true' ); } } );
November 4, 2020 at 1:04 am #1517233BrianHi 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 #1517356DavidStaffCustomer SupportHi there,
add this CSS:
.entry-meta .comments-link:before { content: '| '; }
-
AuthorPosts
- You must be logged in to reply to this topic.