How to remove comment section from page only , not from posts pages?

3 Answers 3


If you want to display comments and the comment form on posts but not on pages, you need to split up the logic in your template file to call comments_template() depending on the type of the item displayed (post or page). There are two ways to do this: either you keep one template file for both items, and use conditional tags:

if (!is_page()) {

The other option is to use both a single.php template file for your posts and a page.php for your pages (see the Template Hierarchy for more information). Just leave out the call to comments_template() in the page template. If there are no other differences between a post and a page layout, one combined template file with conditional tags is probably better for maintainability.

If you want to do this "from a distance", so where the template file already includes a call to comments_template(), you can create a plugin that hooks into the comments_template filter and redirects it to an empty file in the directory (well, it could even be the plugin file itself - since it only contains PHP code, it won't display anything - but this will be confusing to others).

add_filter('comments_template', 'no_comments_on_page');
function no_comments_on_page( $file )
    if ( is_page() ) {
        $file = dirname( __FILE__ ) . '/empty-file.php';
    return $file;

I like a lot this snippet from Hybrid theme at start of comments.php template that will flexibly disable comments if they are not supported or disabled on per-post/per-page basis:

if ( !post_type_supports( get_post_type(), 'comments' ) || ( !have_comments() && !comments_open() && !pings_open() ) )

depending on the theme.

check pages.php code and remove stuff related to comments

be careful not to break the design.

If you can post the code of pages.php here, hope we can help tell u modifications that need to be done

Not the answer you're looking for? Browse other questions tagged or ask your own question.