- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
WordPress. How to enable comments for custom posts.
April 5, 2012
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 ); ?>