I have a custom post type called debate and I want to create some custom fields just on this post type. So, I have this code:

function debate_comment_fields( $fields ) {

   if( is_singular( 'debate' ) ) {


    $fields['options'] = '<p class="comment-form-options"><label for="options">' . __( 'I want to' ) . '</label>' .
        '<input id="first" name="category" type="radio" value="' . get_post_meta(get_the_ID(), 'agree', true) .'" />'. 
        '<input id="second" name="category" type="radio" value="' . get_post_meta(get_the_ID(), 'disagree', true) .'" /></p>';

         return $fields;


Everything is ok on my custom post type, but on the default blog post type the author,email and url are not displayed.

Any idea why?


Yes, alter the single-debate.php and call a custom comment template using comment_template with a parameter, representing your custom comment template.

// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
  • 2
    thanks for this, but is not relevant for what I'm asking for... – agis Oct 31 '13 at 16:48
  • 1
    in functions.php the line if( is_singular( 'debate' ) ) { does not make sense. its only for the template that you are viewing seeis_singular. first register the custom fields in functions php. then show them in the template. – user9 Oct 31 '13 at 18:11
  • 1
    ok, do you have any suggestion on how can I make this work just on that specific post type ? – agis Oct 31 '13 at 18:13
  • 1
    why not check out the plugin above, it seems that would be easiest. i can not test it now unfortunately. but there are many tutorials, see maybe this thread – user9 Oct 31 '13 at 18:17
  • 1
    I don't think you understand exactly what I need. That thread is about something else, the plugin is also about something different. All I need is just a function,conditional to display those custom comment fields on a specific custom type which is already created. – agis Oct 31 '13 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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