Site logo

Archived topic

Adding comment number and link below heading of posts

1 reply · Started by Daniel on November 24, 2022

Viewing posts 1–2 of 2

Hi there!
I want to add the comment number and link below post titles.
I did this on one of my sites: https://drawpaintacademy.com/foreground-middleground-background/
See how it has: November 9, 2022 by Dan Scott 40 Comments
To do this, I had to add the following CSS:
header.entry-header .comments-link:before {
content: " | ";
display: inline-block;
width: auto;
margin: 0 5px 0 0;
font-family: inherit;
}
For some reason, I added this to my other site (which is basically the same set up) but it does not work.
Could someone take a look? Here is a page I tried adding the comments to but it did not work: https://members.drawpaintacademy.com/painting-of-the-month-still-life-kettle-2-by-nicolai-fechin/
Thanks!

Hi Daniel,

Yes, we can take a look. The code you added is just CSS. You'll also need PHP to add the comment count in a single Post's meta.

Try adding this:

add_filter( 'generate_header_entry_meta_items', function( $items ) {
    $items[] = 'comments-link';

    return $items;
} );

add_action( 'wp', function() {
    if ( is_single() ) {
        add_filter( 'generate_show_comments', '__return_true' );
    }
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

This archived topic is closed to new replies.