Forums

No comments on specific category pages? (12 posts)

  1. streetlight708
    Member
    Posted 10 months ago #

    Hey guys,

    I'm trying to remove the ability to leave comments on a specific category on the blog.

    All the threads I've found here are from older versions of WP, and I'm not completely comfortable with php. Can anybody help?

    Thanks!

  2. nsathees
    Member
    Posted 10 months ago #

    you will have to get comfortable with php to get that archived. Within loop check in_category template tag and remove the comment code accordingly.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    @streetlight708: Does your theme have a category.php template file?

  4. streetlight708
    Member
    Posted 10 months ago #

    it does! Is the solution in there?

  5. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Sorry - no. Wrong topic. You need to edit single.php and change:

    <?php comments_template( '', true ); ?>

    to:

    <?php if( !in_category('apples') ) comments_template( '', true ); ?>
    http://codex.wordpress.org/Template_Tags/in_category

  6. streetlight708
    Member
    Posted 10 months ago #

    Hmm. I can't find that in this code:

    get_header(); ?>
    
    		<div id="container">
    			<div id="content" role="main">
    
    			<?php
    			/* Run the loop to output the post.
    			 * If you want to overload this in a child theme then include a file
    			 * called loop-single.php and that will be used instead.
    			 */
    			get_template_part( 'loop', 'single' );
    			?>
    
    			</div><!-- #content -->
    		</div><!-- #container -->

    Should I just add it in?

  7. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    What theme are you using?

  8. streetlight708
    Member
    Posted 10 months ago #

    it's a custom theme we paid someone to make - I'm thinking they just spit it out

  9. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Site url?

  10. TheFreakstar
    Member
    Posted 10 months ago #

    I'm trying to solve the same issue. I added the code you suggested into the single post template (single.php)

    <?php if( !in_category('apples') ) comments_template( '', true ); ?>

    changed the apples for my category name, and it doesn't seem to work. Does the permalink format have anything to do with it?

  11. Alkorr
    Member
    Posted 10 months ago #

    Hi there! How can this code work for tags as well?

    Thanks a lot! :)

  12. Alkorr
    Member
    Posted 10 months ago #

    Ok, don't bother, I've found out myself: is_tag

    But now, how is it possible to modify <?php comments_popup_link(); ?> so when the comments template doesn't show, the comment is: 'Comments not avalable'. Or else it still says 'No comments yet' and it is linked to the 'supposed' comments form.

    Not sure anybody knows but I'm asking anyway. Thanks for your help! :)

Reply

You must log in to post.

About this Topic