Site logo

Archived topic

comments-link on post page

3 replies · Started by Darius on December 1, 2020

Viewing posts 1–4 of 4

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?

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/

it's working. thanks

No problem :)

This archived topic is closed to new replies.