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've created a custom post type, and i want to display and allow comments.

I have this in function.php :

// Add Custom Post Types
    add_action( 'init', 'thm_post_types' );

// Add Custom Post Types Function
    require_once ( THEME_INCLUDES . 'theme-post-types.php' );

    require_once ( THEME_INCLUDES . 'theme-comments.php' );

In my theme-post-types.php i have :

register_post_type( 'product',
        'labels' => array(
            'name' => 'Product Items',
            'singular_name' => 'Product' ,
            'add_new' => 'Add New Product',
            'add_new_item' => 'Add New Product Item' ,
            'edit' => 'Edit Product',
            'edit_item' => 'Edit Product Item',
        'description' => 'Product Items.' ,
        'public' => true,
        'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ), // ***** i believe this is the problem ******
        'taxonomies' => array('category', 'post_tag')

register_taxonomy( 'product_category', array( 'product' ), array( 'label' => "Categories", "singular_label" => "Category" ) );

And finally in my theme-comments.php :

function thm_format_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    <div class="comment" id="comment-<?php comment_ID() ?>">
        <div class="avatar"><?php echo get_avatar( $comment, $size='80' ); ?>
        <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) ?>
        <div class="comment-text">
            <cite><?php comment_author_link(); ?></cite>
            <small><?php comment_date( 'F d, Y - G:i ' ); ?></small>
            <div class="separator-line" style="margin-bottom:10px; margin-top:5px;"></div>
            <?php if ($comment->comment_approved == '0') : ?>
                <p><em><?php _e( 'Your comment is awaiting moderation.' ); ?></em></p>
            <?php endif; ?>
            <?php comment_text() ?>
        <div class="clear"></div>

In my custom post type php i have :

<div id="tabs-3">
            <?php comments_template(); ?>

Custom post shows content, but it's not showing comments or comment form... Any ideas?

share|improve this question

migrated from stackoverflow.com Sep 30 '11 at 0:01

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

Have you tried adding comment support to your custom post type, via add_post_type_support()?


add_post_type_support( 'product', array( 'comments' ) );
share|improve this answer

After this, you need to enable "Discussions" and "Comments" in the screen options in the backed. Once you do that, you can enable/disable comments for each custom post type.

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.