Site logo

Archived topic

How to display total comments below post title

9 replies · Started by WP on July 21, 2020

Viewing posts 1–10 of 10

Hi,

I would like to display total comments below post title(h1) and before post description(paragraph). I looked around options but could not find such option. Also, I've added CrowdSignal thumbs up/down widget which is not aligned properly. I'm trying to have it displayed right below post title and once displaying total comments is possible, I could like to have thumbs up/down displayed before comments similar to below.
https://crowdsignal.com/features/

https://pasteboard.co/JiHqB06.png

Hi there,

Can you:

- Disable the caching plugin first.

- Do you only want the comment link to display in single posts but not archives?

- As for CrowdSignal thumbs up/down widget, that's something you will need to check with their support as the CSS is all from the plugin from what I can see.

Leo,
This site is hosted in WordPress.com. I don't see caching plugin being activated.

Af for comments display link - I only want the link to display in single post (including total comments).

Let me check with CrowdSignal on resolving thumbs up/down widget position issue.

Ok this takes a couple of steps but try:

- Activate comment count for Archives in the customizer:
https://docs.generatepress.com/article/blog-content-layout/#archives

- Add this PHP snippet:

add_filter( 'generate_header_entry_meta_items', function( $items ) {
    if ( is_single() ) {
        $items = array(
            'comments-link',
        );
    } return $items;
} );

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

Then this CSS:

.single .comments-link {
    display: block;
}
footer.entry-meta .comments-link {
    display: none;
}

Adding CSS: https://docs.generatepress.com/article/adding-css/

Leo,
Thumb up/down are being displayed using CrowdSignal plugin. I have ticket open with their support to see if after_entry_header hook could be utilized.

Regarding displaying comment link below title (in post meta), I wanted to replace 'Leave a Comment' with 'Add Comment' with below code, but it not replacing the text.

add_filter( 'generate_leave_comment','st_custom_leave_comment' );
function st_custom_leave_comment() {
    return 'Add Commment';
}

add_filter( 'generate_header_entry_meta_items', function( $items ) {
    if ( is_single() ) {
        $items = array(
            'comments-link',
        );
    } return $items;
} );

Ok - this worked. It seems that WordPress.com business plan uses custom comment form.

add_filter( 'gettext', function( $text, $original, $domain ) {
    if ( 'Leave a comment' === $text && 'generatepress' === $domain ) {
        return 'Add Commment';
    }

    return $text;
}, 10, 3 );

Glad you've figured out and thanks for sharing!

This archived topic is closed to new replies.