{"id":16103,"date":"2012-04-05T02:50:46","date_gmt":"2012-04-05T06:50:46","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=16103"},"modified":"2016-02-24T05:29:12","modified_gmt":"2016-02-24T10:29:12","slug":"wordpress-how-to-enable-comments-for-custom-posts","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/wordpress-how-to-enable-comments-for-custom-posts.html","title":{"rendered":"WordPress. How to enable comments for custom posts."},"content":{"rendered":"<p>\r\n<p>This tutorial shows how to enable comments for the custom posts in WordPress. <\/p>\r\n<p><strong>1) <\/strong>Open<strong> &quot;wp-content\/themes\/theme\u0425\u0425\u0425\u0425\/includes\/theme-init.php&quot;<\/strong> file, and search for the functions that creates custom posts type:<\/p>\r\n<pre class=\"brush:php\">\r\n\/* Services *\/\r\n  function my_post_type_services() {\r\n  register_post_type( 'services',\r\n  array(\r\n  'label' =&gt; __('Services'),\r\n  'public' =&gt; true,\r\n  'show_ui' =&gt; true,\r\n  'show_in_nav_menus' =&gt; false,\r\n  'menu_position' =&gt; 5,\r\n  'rewrite' =&gt; array(\r\n  'slug' =&gt; 'services-view',\r\n  'with_front' =&gt; FALSE,\r\n  ),\r\n  'supports' =&gt; array(\r\n  'title',\r\n  'thumbnail',\r\n  'editor')\r\n  )\r\n  );\r\n <\/pre>\r\n<p><strong>2)<\/strong> In the <strong>&#8216;supports&#8217; <\/strong>array add <strong>&#8216;comments&#8217;<\/strong>:<\/p>\r\n<pre class=\"brush:php\">'supports' =&gt; array(\r\n  'title',\r\n  'thumbnail',\r\n  'comments',\r\n  'editor')\r\n  )<\/pre>\r\n<p>Now you can access custom posts via the WordPress admin panel and enable comments in the <strong>Discussion<\/strong> section. <\/p>\r\n<p>3) If you still don&#8217;t see coments check what single post template is used. For example if the custom post use such single post template files as <strong>single-testi.php, single-team.php<\/strong> etc you need to enable comments in those files. To do this please add the following line where you want comments to be displayed:<\/p>\r\n<pre class=\"brush:php\">&lt;?php comments_template( '', true ); ?&gt;<\/pre>\r\n<\/p>\r\n<p>\r\n<\/p>\r\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to enable comments for the custom posts in WordPress.<\/p>\n","protected":false},"author":2,"featured_media":16807,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[728],"tags":[874,592,2405],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/16103"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=16103"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/16103\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/16807"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=16103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=16103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=16103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}