Take Advantage of old rates before 31 December 2011, submit your website to Dir.vc Web Directory Now!
RSS Feed Directory Blog Articles Submit Site Popular Sites Contact Us
Web Directory » Blog
|__ Wordpress: How to remove “Comments Off” php code snippet

WordPress: How to remove “Comments Off” php code snippet

  - November 5th, 2011 by Web Directory | Posted in Wordpress hacks   No Comments »
Email this  Email  |   Print This Post Print This Post     

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: , , ,

Leave a Reply

Captcha
Enter the letters you see above.



Entries (RSS) and Comments (RSS) Blog – Dir.vc :: Web Directory is proudly powered by WordPress - Site By : M-Solutions India