Posted By

richbdesign on 02/23/13


Tagged


Versions (?)

Remove comments from pages


 / Published in: PHP
 

WP comments

  1. <?php
  2.  
  3. //First add an empty file your template folder (sub theme), nothing in. No code, nothing. Just give it a name like "no-comments-please.php" and upload it to your server.
  4.  
  5. //After that you can add something like this to your functions.php in order to call the file when pages are called:
  6.  
  7.  
  8. add_filter( 'comments_template', 'remove_comments_template_on_pages', 11 );
  9.  
  10. function remove_comments_template_on_pages( $file ) {
  11. if ( is_page() )
  12. $file = STYLESHEETPATH . '/no-comments-please.php';
  13. return $file;
  14. }
  15.  
  16. //After that comments will be removed from all pages. If you like you can enhance the function to do whatever you want.
  17.  
  18. ?>

Report this snippet  

You need to login to post a comment.