Open Comments & Trackbacks in WordPress Globaly

I love when things go wrong!  It gives me an opportunity to, perhaps, enlighten people with solutions that may find themselves in a familiar situation.  Recently, I have been toying with some comments systems on the site, namely Intense Debate and DISQUS.  In the process of experimenting with both of these services I noticed that there had been no comments since disabling them.  Upon further investigation I had realized that after disabling Intense Debate all comments and trackbacks / pingbacks had been disabled.

There are a few ways you can go about re-enabling comments and trackbacks / pingbacks:

  1. Edit every single post to allow them
  2. Perform a Bulk Action page by page of posts
  3. Perform a PHP query via phpMyAdmin – easy enough, if you have access to phpMyAdmin
    1. You can run an SQL query using the WP-DBManager plugin if you don’t have access to phpMyAdmin
  4. Add some code to your functions.php file

phpMyAdmin / WP-DBManager Plugin

This is originally how I fixed my problem.  Since then, I have decided to implement the functions.php method on many of the sites I work with now.

Query to turn on Comments

UPDATE wp_posts SET comment_status = 'open';

Query to turn off Comments

UPDATE wp_posts SET comment_status = 'closed';

Query to turn on Pingbacks

UPDATE wp_posts SET ping_status = 'open';

Query to turn off Pingbacks

UPDATE wp_posts SET ping_status = 'closed';

functions.php
To open all comments / trackbacks and pingbacks on posts and KEEP them open.

// ----------------------------------------------------------------------
// Start Comment / trackbacks and pingbacks status update
// ----------------------------------------------------------------------
global $wpdb;
$pingfuturestatus = array('ping_status' => 'open');
$pingcurrentstatus = array('ping_status' => 'closed');
$commentfuturestatus = array('comment_status' => 'open');
$commentcurrentstatus = array('comment_status' => 'closed');
$wpdb->update($wpdb->posts, $pingfuturestatus, $pingcurrentstatus);
$wpdb->update($wpdb->posts, $commentfuturestatus, $commentcurrentstatus);
// ----------------------------------------------------------------------
// End Comment / trackbacks and pingbacks status update
// ----------------------------------------------------------------------

Note: These functions are not of my own creation, simply things I have found along the way.  If you are the author of this function, please let me know so I can properly credit you with your work!

Your thoughts?

About Joe D

I have always had a passion for everything computing. In early 2000, I decided to take my passion to the web. Thus, C.O.D. was born. Through the years we have made many great friends at C.O.D. and hope to continue our journey for years to come.

Check Also

Manage Multiple WordPress Sites with InfiniteWP

Running your website, or websites, on WordPress is an easy choice as the flexibility the …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.