Comments not showing in custom post type – WordPress

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',
    array(
        '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>
        <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>
        <div class="clear"></div>
    </div>
    </li>

In my custom post type php i have :

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

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

3 Answers
3

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

e.g.

<?php
add_post_type_support( 'product', array( 'comments' ) );
?>

Leave a Comment