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

I know that I can require all of the comments on my site to be moderated, but is there a way of forcing moderation for a specific custom post type (i.e. my CPT "species") whilst allowing instantaneous comments across the rest of the site?

Thanks in advance,

share|improve this question
up vote 1 down vote accepted

Yes, this is possible. Comment moderation is an option, and is retrieved like any other option:


the get_option function applies a filter before returning the value...

return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );

So what you'll want to do is add_filter('option_comment_moderation', 'check_moderable_post_types') and in your check_moderable_post_types function, check to see if the current post's post type is species. If so, return 1, and if not return the $value that is passed to the function!

Edit: This should do the trick:

add_filter('option_comment_moderation', 'check_moderable_post_types');
function check_moderable_post_types($value) {
    if (get_post_type() == 'species') return 1;
    return $value;
share|improve this answer
Hi Matthew, thanks for this - works perfectly. Much appreciated! – dunc Jan 22 '12 at 20:03

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.