Site logo

Archived topic

Comment count not showing in single posts meta

3 replies · Started by Benjamin on December 1, 2020

Viewing posts 1–4 of 4

Hi,

I'm trying to get the comments count to show alongside the author name and updated date in single posts but it doesn't seem to work.

As you can see, the comments count just doesn't appear:
https://frenchtogether.com/french-words-in-english/

Here is the code I have:

add_filter( 'generate_post_author_output', function( $output ) {
    if ( ! is_singular() ) {
        return $output;
    }

    return sprintf( ' <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' ) )
        )
    );
} );

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
        'author',
		'comments-link',
		'date',
    );
} );

add_filter( 'generate_footer_entry_meta_items', function() {
    return array(
        'categories',
    );
} );

And here is the CSS I have:

.byline img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    position: relative;
    vertical-align: middle;
    margin: 0 10px 0 0;
}

.single-post .entry-content img {
	  box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.entry-meta a{
	margin-right: 10px;
}

.single .comments-link {
    display: inline-block;
}

Any idea what's wrong?

Thanks

Hi there,

Try adding this:

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

Let me know :)

Thanks, that worked :)

You're welcome :)

This archived topic is closed to new replies.