WordPress.org

Ready to get started?Download WordPress

Forums

How do I re-open comments on individual posts while keeping the majority closed (6 posts)

  1. CameronMiquelon
    Member
    Posted 2 years ago #

    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?

  2. snowcrash
    Member
    Posted 1 year ago #

    This is a useful function - did you manage to solve this?

    thanks

  3. keesiemeijer
    moderator
    Posted 1 year ago #

    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.

  4. snowcrash
    Member
    Posted 1 year ago #

    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

  5. keesiemeijer
    moderator
    Posted 1 year ago #

    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?

  6. CameronMiquelon
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic