Support » Fixing WordPress » How do I re-open comments on individual posts while keeping the majority closed

  • Hello!

    In my overall Discussion settings, I have it set up so that comments close after 14 days, as I wish to keep things moving along and discourage “necro-commenting,” as it were.

    However, I have two very popular posts (both are older than 14 days) that I want to re-open for commenting (and only those two).

    The Discussion settings on each post are checked to allow comments and pingbacks, but are overridden by my overall settings, keeping the posts closed to new comments.

    How do I override the override so that my commentariat can continue to comment on those two popular posts while keeping the rest of the older stuff closed?

Viewing 5 replies - 1 through 5 (of 5 total)
  • This is a useful function – did you manage to solve this?

    thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this in your theme’s functions.php:

    add_filter( 'comments_open', 'my_comments_open', 10, 2 );
    
    function my_comments_open( $open, $post_id ) {
    	if(!is_admin()){
    
    		// change these post ID's to have comments open
    		$open_comments_post_IDs = array(762,758,1514);
    
    		if(in_array($post_id, $open_comments_post_IDs) && !$open) {
    			$open = true;
    		}
    
    	}
    
    	return $open;
    }

    And change the post ID’s in $open_comments_post_IDs = array(762,758,1514); where you want the comments to always be open.

    Thanks for the quick response.

    Added the code to my functions file with my post ID’s – though doesn’t make a difference. Comments on those posts still are displayed as closed.
    I’m running WP 2.9.2

    Moderator keesiemeijer

    (@keesiemeijer)

    That’s strange. It works on my site. Have you looked at the single post (with the id in the array()) if the comment form appears?

    Thread Starter CameronMiquelon

    (@cameronmiquelon)

    Hello all!

    Thank you for the help, but this issue was already resolved for me two months ago through the Thesis community; the solution above is what was recommended to me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I re-open comments on individual posts while keeping the majority closed’ is closed to new replies.