WordPress: How to remove “Comments Off” php code snippet
I came across a project where I had to make a page without any comment box! And no line saying comments off!
Googleling didnt help much, Almost all the solutions online went to editing the theme files.
Objective: Remove the comment box/ “Comments Off” line from the page, where comments were off!
open your current themes functions.php and add the following there at the end,
Code:
function comment_style() {
global $post;
// please enter the Pages ID's below,
// you can see the ID when you goto edit page in the URL address bar,
// ... domain.com/wp-admin/post.php?post=2&action=edit
// [ the Page ID here is 2 ] //
$no_comment_pages = array(2, 3, 5);
if(in_array($post->ID, $no_comment_pages))
{
echo '<style type="text/css">div.feedback, .feedback {visibility:hidden;}</style>';
}
}
add_action('wp_print_styles', 'comment_style');
Thats it!
Cheesy
Tags: comment box, comment page, remove comments off, Wordpress
This entry was posted
on Saturday, November 5th, 2011 at 10:58 pm and is filed under Wordpress hacks.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
WordPress: How to remove “Comments Off” php code snippet
- November 5th, 2011 by Web Directory | Posted in Wordpress hacks No Comments »WordPress: How to remove “Comments Off” php code snippet
I came across a project where I had to make a page without any comment box! And no line saying comments off!
Googleling didnt help much, Almost all the solutions online went to editing the theme files.
Objective: Remove the comment box/ “Comments Off” line from the page, where comments were off!
open your current themes functions.php and add the following there at the end,
Code:
function comment_style() { global $post; // please enter the Pages ID's below, // you can see the ID when you goto edit page in the URL address bar, // ... domain.com/wp-admin/post.php?post=2&action=edit // [ the Page ID here is 2 ] // $no_comment_pages = array(2, 3, 5); if(in_array($post->ID, $no_comment_pages)) { echo '<style type="text/css">div.feedback, .feedback {visibility:hidden;}</style>'; } } add_action('wp_print_styles', 'comment_style');Thats it!
Cheesy
Tags: comment box, comment page, remove comments off, Wordpress
This entry was posted on Saturday, November 5th, 2011 at 10:58 pm and is filed under Wordpress hacks. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.