Skip Navigation

[Resolved] Remove comment box from all posts

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 3 replies, has 2 voices.

Last updated by Mateus Getulio 1 year, 4 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2636181

jww

I have a custom post type. I have the Comments box unchecked in the Post type settings "Sections to display when editing" in the Toolset settings. I have comments disabled in the general WordPress settings. Yet, there is a Leave a comments box on the front end of this post type. How do I get rid of it? I don't want comments on it. There are no comments, the site isn't live. I don't see anywhere else to entirely disable comments on the post type created with Toolset.

Thanks.

#2636749

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thank you for contacting our support.

To disable comments from new and existing posts in a particular post type, you can follow these steps:

1. Please make sure that the "Comments" option is enabled in that post type's settings.
( example screenshot: hidden link )

2. Next, go to the post list of this post type in the admin area, and use bulk edit option to set comments to "Do not allow" for all existing posts.
( example screenshot: hidden link )

3. Once comments have been disabled for all existing posts, you can disable the comment option for this post type that was mentioned in step 1, so that they can't be turned on for future posts.

If it doesn't work, can you please try adding the following code to your theme's functions.php file? This should forcefully disable the comment section based on the CPT you select in the code.

add_action( 'template_redirect', 'pp_disable_comments' );
function pp_disable_comments($post_object) { 	
	global $post;
	$obj = get_post_type_object($post_object);	
	// test CPT
	if ($post->post_type == 'post') {		
		// disable comment section
		$post->comment_status="closed";
	}	 	
}

I hope this helps and please let me know if you need any further assistance around this.

Best regards,
Mateus

#2636759

jww

Thanks, Mateus.
I don't understand why they would be allowed/displayed in the first place if I have that first setting you mentioned unchecked from the beginning as well as the main Discussion settings in admin set to unchecked for allow comments. So why would I have to go through those steps of turning them on and off if they were unchecked from the beginning?

I used the snipped in this link which worked to turn them off always
hidden link

But I'd like to understand in general why a new post type wouldn't respect the do not allow comments choices in both admin and Toolset settings?

#2636857

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thank you for sharing your solution.

This situation could happen mainly due to one of the two issues:

1 - Another plugin(like the one you just installed) or your theme could be overriding Toolset's comments setting for your CPTs. To check this you can test in minimal environment with a default theme and all non-Toolset plugins disabled.

2- Legacy Data. Sometimes, old posts that were created when comments were allowed will still have comments enabled, even if you've now globally turned them off. Bulk editing helps resolve this, like it was done here: https://toolset.com/forums/topic/hide-comments-in-custom-post-type-single-page-content-template/#post-279463 There are some more details about it in this thread as well: https://toolset.com/forums/topic/disabling-comments-for-a-post-type-or-in-a-layout/#post-1559711

Please do not hesitate to contact us again if you have any other doubt.

Kind regards,

Mateus