If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)

captcha

WordPress. How to enable comments for custom posts.

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 ); ?>
WordPress. How to enable comments for custom posts., 5.0 out of 5 based on 1 rating