• Resolved udidol

    (@udidol)


    Hi, I created a CPT (via a one-function plugin I wrote) without support for comments, and I still get a comments section in my custom posts.

    I even tried to remove comments support with a function in a child theme’s functions.php:

    function remove_chapters_comments() {
    	remove_post_type_support( 'Chapters', 'comments' );
    }
    add_action( 'init', 'remove_chapters_comments', 1 );

    It doesn’t work. Nothing I do removes the comments option from the CPT. Even under Appearance > Customize > Blog > Single Post, if I click on the eye icon next to “comments”, it only cancels them out in regular posts, not in the CPT.

    How do I cancel comments on my CPT??

    Thanks

    • This topic was modified 7 years, 4 months ago by udidol.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author oceanwp

    (@oceanwp)

    Hello, you have to create a file in your child theme.
    Create a folder “partials”, in this folder, create another folder named “single”, create a php file named “layout-chapters.php”, this file will be the contents of your cpt.
    Take example on “oceanwp/partials/single/layout.php”, for example for your cpt, you can enter this code in your file:

    <article id="post-<?php the_ID(); ?>" itemprop="blogPost" itemscope="itemscope" itemtype="https://schema.org/BlogPosting">
    
    	<?php
    	// Get posts format
    	$format = get_post_format();
    
    	// Featured Image
    	if ( ! post_password_required() ) {
    
    		$format = $format ? $format : 'thumbnail';
    		
    		get_template_part( 'partials/single/media/blog-single', $format );
    
    	}
    
    	// Title
    	get_template_part( 'partials/single/header' );
    
    	// Meta
    	get_template_part( 'partials/single/meta' );
    
    	// Content
    	get_template_part( 'partials/single/content' );
    
    	// Tags
    	get_template_part( 'partials/single/tags' );
    
    	// Social Share
    	if ( OCEAN_EXTRA_ACTIVE ) {
    		do_action( 'ocean_social_share' );
    	}
    
    	// Next/Prev
    	get_template_part( 'partials/single/next-prev' );
    
    	// Author Box
    	get_template_part( 'partials/single/author-bio' );
    
    	// Related Posts
    	get_template_part( 'partials/single/related-posts' ); ?>
    
    </article>
    Thread Starter udidol

    (@udidol)

    Hi,
    Thank you for your response! Your theme is great.

    How is this layout.php template different than the one in the original theme?
    Anyway, I will try doing what you suggested tonight and will update on the results.

    Thanks!

    Theme Author oceanwp

    (@oceanwp)

    Hello, thank you. This one is different because there is no comment box ??

    Thread Starter udidol

    (@udidol)

    Hey,
    Thank you, I got it to work! After going over the files I noticed it wasn’t working because I was editing the wrong layout file… I created my new layout file before in ‘partials/entry/’. Now that I created the new file in ‘partials/single’ and changed the reference in single-chapters.php it works fine.

    I do have a follow-up question – for some reason, I don’t see the “next post” and “previous post” links in my CPT single posts… Is there anything I need to do in the theme settings to make them show up? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t cancel comments in CPT’ is closed to new replies.