[Resolved] comments-link on post page

Home Forums Support [Resolved] comments-link on post page

Home Forums Support comments-link on post page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1561483
    Darius

    I use this code from documentation page

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

    why on homepage the comment link is displayed and on single post is not working?

    #1561760
    Leo
    Staff
    Customer Support

    Hi there,

    Try this for your full function:

    add_filter( 'generate_header_entry_meta_items', function() {
    	$comments_number = get_comments_number( $post_id );
        return array(
    	    'date',
            'comments-link',
        );
    } );
    add_action( 'wp', function() {
        if ( is_single() ) {
            add_filter( 'generate_show_comments', '__return_true' );
        }
    } );

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

    #1562230
    Darius

    it’s working. thanks

    #1562380
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.