Categories

Featured templates

WordPress. How to enable comments for custom posts.

Chris Diaz April 5, 2012
Rating: 3.6/5. From 8 votes.
Please wait...

This tutorial shows how to enable comments for the custom posts in WordPress.

1) Open "wp-content/themes/themeХХХХ/includes/theme-init.php" file, and search for the functions that creates custom posts type:

/* Services */
  function my_post_type_services() {
  register_post_type( 'services',
  array(
  'label' => __('Services'),
  'public' => true,
  'show_ui' => true,
  'show_in_nav_menus' => false,
  'menu_position' => 5,
  'rewrite' => array(
  'slug' => 'services-view',
  'with_front' => FALSE,
  ),
  'supports' => array(
  'title',
  'thumbnail',
  'editor')
  )
  );
 

2) In the ‘supports’ array add ‘comments’:

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

Now you can access custom posts via the WordPress admin panel and enable comments in the Discussion section.

3) If you still don’t see coments check what single post template is used. For example if the custom post use such single post template files as single-testi.php, single-team.php etc you need to enable comments in those files. To do this please add the following line where you want comments to be displayed:

<?php comments_template( '', true ); ?>

Clean Simple Wordpress Themes
This entry was posted in WordPress Tutorials and tagged comment, post, WordPress. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket