WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Pseudo code might look like:

if it's this type of post
    display comments and comment box
    forget it

This same type of code should also allow someone to have HTTP requests if it's some page, or some kind of page/post but not all of them.

share|improve this question
Hi Daniel, please, instead of some requirement, present us your research and attempts to solve the issue yourself. See How to Ask. – brasofilo May 12 '13 at 5:05
You have to put some fixed criteria, how you want to filter the comment box. It can be of certain category/categories, or other taxonomy types; can be of certain post type; can be of certain author... so first come up to this point, then your answer will follows. Thanks. – Mayeenul Islam May 12 '13 at 18:32

In principle you should be able to achieve that by using categories for your posts. So while your normal loop for the single.php might look like this (I'll just leave the markup I had in there since I took this out of a file I had lying around. It may of course be different from yours.)

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_title(); ?>
    <p><em><?php the_date(); ?>, <?php the_time(); ?></em></p>

    <?php the_content(); ?>
  <small>Permalink: <?php the_permalink(); ?></small>

    <?php comments_template(); ?>

<?php endwhile; else: ?>
    <p><?php _e('Sorry, diese Seite existiert nicht.'); ?></p>
<?php endif; ?>

You would get another another if to check if it's in the category. It should more or less like this Codex article.
So you'll just have to put the posts in question in a "no comments" category and make sure that this category is displayed without the

<?php comments_template(); ?>

part of the loop. I think you should be fine then.

share|improve this answer

In the loop you should check for the post type, so something like:

if (get_post_type() == "Your_Allowed_Post_Type"){
    //No COMMENTS HERE , show what you want..or nothing :)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.