0
votes

I have created a custom post type, and a single page template which works fine. But I'm having a problem with enabling comments on the single pages for it.

This is my function:

    add_action('init', 'vblog'); 
    function vblog() {
    register_post_type('vblog', array(
    'labels' => array(
            'name' => __( 'VTV' ),
            'singular_name' => __( 'VTV' ),
            'add_new' => 'Add New VBlog',
            'add_new_item' => 'Add New VBlog',
            'edit' => 'Edit VBlog',
            'edit_item' => 'Edit VBlog',
            'new_item' => 'New VBlog',
            'view' => 'View VBlogs',
            'view_item' => 'View VBlog',
            'search_iteme' => 'Search VBlogs',
            'not_found' => 'No VBlogs Found',
            'not_found_in_trash' => 'No VBlogs found in Trash',
            'parent' => 'Parent VBlog',
    ),
    'public' => true,
    'supports'  =>  array('title', 'editor','custom-fields', 'thumbnail', 'revisions', 'comments'),
    'taxonomies' => array('category', 'post_tag')
));

}

So I made sure that I added "comments" in the support array. Help please!!!

2
Does the single template of custom post type has comments added. Something like <?php comments_template( '', true ); ?>tamilsweet

2 Answers

0
votes

Expanding on the comment as an answer.

You have correctly registered the post_type to support comments. In your single-{post_type}.php template you need to call the comments template inside the loop ( between endwhile and else endif) .

if ( comments_open() || '0' != get_comments_number() )
        comments_template( '', true );
0
votes

add this code single-vblog.php

comments_template( '', true ); 

If show Comment closed you can run this command in phpmyadmin

UPDATE wp_posts SET comment_status = 'open' WHERE post_type = 'vblog';