enable comments for custom post type

In wordpress we can create the custom post types. Now everybody is using custom post types in wordpress and need comments functionality for custom post types also. Custom post types are very important feature of wordpress. For enabling the comments for custom post type just use the following line.

enable comments for custom post type

'supports' => array('title','editor','author','thumbnail','excerpt','comments')

Following line will add the title, thumbnail, excerpt and comments functionality to your custom post type.

enable comments for custom post type
enable comments for custom post type

For more information use check my following code. I used following code in my functions.php file.

add_action('init', 'wordpress_themes');
 function wordpress_themes() {
 $wp_themes_args = array(
 'label' => __('Wordpress Themes'),
 'singular_label' => __('Wordpress Themes'),
 'public' => true,
 'show_ui' => true,
 'capability_type' => 'post',
 'hierarchical' => false,
 'rewrite' => true,
  'supports' => array('title','editor','author','thumbnail','excerpt','comments'),
           'taxonomies' => array('category', 'post_tag') // this is IMPORTANT

 );
 register_post_type('wordpress-themes',$wp_themes_args);
 }

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

4 thoughts on “enable comments for custom post type”

  1. Perfect – I had completely missed adding the comments into the string and wondered why they were showing up as closed. These new Post Types are brilliant but not a lot of info around on how to maximise them!

Leave a Reply to Purab Kharat Cancel reply

Your email address will not be published.