How to Display Comments on Selected Pages in WordPress?

By default WordPress adds a comment box on all posts and pages but sometime when you use WordPress as a CMS you may want to disable comments on some pages. But how to do it, please take a look the below code,

Goto > Appearance > Editor > page.php and locate

<!--?php comments_template( '', true );?-->

and replace it with following code

<!--?php  if (  is_page(array(111,12,55))) {  comments_template( '', true );  }?-->

Please note: replace 111,12,55 with your page ID, it’ll only display comments on that particular pages which ID you mentioned in this code.

Advertisements