{"id":1354,"date":"2015-11-28T20:29:37","date_gmt":"2015-11-28T11:29:37","guid":{"rendered":"http:\/\/www.santoshkori.com\/blog\/?p=1354"},"modified":"2015-11-28T20:29:37","modified_gmt":"2015-11-28T11:29:37","slug":"how-to-display-selected-category-names-of-custom-post-type-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.santoshkori.com\/blog\/how-to-display-selected-category-names-of-custom-post-type-in-wordpress\/","title":{"rendered":"How to display selected category names of custom post type in wordpress"},"content":{"rendered":"<p>Here is code snippet to display selected category names of custom post type in wordpress.<\/p>\n<p>To get the categories of a custom post type you have call get_the_terms() and setup the registered category name like this<\/p>\n<pre><code>&lt;?php\r\n$terms = get_the_terms( $post-&gt;ID , 'myposttype_category' );\r\nforeach ( $terms as $term ) {\r\n  echo $term-&gt;name;\r\n}\r\n?&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is code snippet to display selected category names of custom post type in wordpress. To get the categories of a custom post type you have call get_the_terms() and setup the registered category name like this &lt;?php $terms = get_the_terms( $post-&gt;ID , &#8216;myposttype_category&#8217; ); foreach ( $terms as $term ) { echo $term-&gt;name; } ?&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,11],"tags":[708,707,706,709],"class_list":["post-1354","post","type-post","status-publish","format-standard","hentry","category-wordpress","category-wordpress-freelancer","tag-category-names-of-custom-post-type","tag-custom-post-type","tag-display-selected-category-names-of-custom-post-type","tag-get-selected-category-names-of-custom-post-type"],"_links":{"self":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/comments?post=1354"}],"version-history":[{"count":1,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1354\/revisions"}],"predecessor-version":[{"id":1355,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1354\/revisions\/1355"}],"wp:attachment":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/media?parent=1354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/categories?post=1354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/tags?post=1354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}