[Support request] Comment count in meta of single post

Home Forums Support Comment count in meta of single post

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1477158
    Dong

    Hi guys,

    It seems the latest update breaks the comment counts in the meta of a single post. And all the existing tricks don’t work — they only work for the meta of the archive. Basically, I’d like to have the meta in this format:

    [Date] • Writer • Comment count (the first two are already there like in the post below.)

    https://dongknows.com/get-your-home-wired-with-network-cables/

    Better yet, if possible, I’d like the meta to be:

    [Date] • Writer • [Number of minutes] to read • Comment count

    How can I bring them back? Thanks.

    -Dong.

    #1477162
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Can you share the current functions you were using that are no longer working?

    #1478073
    Dong

    I used the code below but it has two problems:

    1. The comment count only appears on the archive page, not in a single post.
    2. On the archive page, it shows in two places, below the Headline and also below the excerpt. When I turn off “Display comment count” using the Layout Customization then it disappears in both.

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
        
    	  'author',        
    	  'date',
    	  'comments-link',
    	
        );
    } );
    add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) {
        if ( '' === $item ) {
            return '';
        }
        if ( 'comments-link' === $item ) {
            return ' • ';
        }
        if ( 'date' === $item ) {
            return ' • ';
        }
    
        return $output;
    }, 50, 2 );
    #1478842
    Tom
    Lead Developer
    Lead Developer

    Add this as well:

    add_action( 'wp', function() {
        if ( is_single() ) {
            add_filter( 'generate_show_comments', '__return_true' );
        }
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array_diff( $items, array( 'comments-link' ) );
    } );
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.