{"id":2472,"date":"2026-10-20T08:33:27","date_gmt":"2026-10-20T07:33:27","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/gd-single-taxonomies-only-categories\/"},"modified":"2026-10-20T08:56:59","modified_gmt":"2026-10-20T07:56:59","slug":"gd-single-taxonomies-only-categories","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/gd-single-taxonomies-only-categories\/","title":{"rendered":"How to show only categories, or only the main category, on a listing"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The GD &gt; Single Taxonomies block (<code>&#091;gd_single_taxonomies&#093;<\/code>) shows a listing&#8217;s categories and tags on the details page. Its options cover most changes without code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Taxonomy: categories and tags (default), categories only (<code>cats<\/code>) or tags only (<code>tags<\/code>).<\/li>\n\n\n\n<li>Limit: the most terms to show.<\/li>\n\n\n\n<li>Prefix: the taxonomy name such as &#8220;Place Category:&#8221; (default), icons, or none (<code>0<\/code>).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So this shows the categories only, with no label in front:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">&#091;gd_single_taxonomies taxonomy=&quot;cats&quot; prefix=&quot;0&quot;&#093;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Show only the main category with its parents<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every listing has a <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/how-tos\/what-is-the-default-category-field-for\/\">default category<\/a>, the main one used for its map icon and similar things. GD &gt; Single Taxonomies lists categories in alphabetical order, so <code>limit=&quot;1&quot;<\/code> gives you the first one alphabetically, which may not be the default.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To show just the default category, with its parent categories before it, add this snippet. It creates a <code>&#091;my_gd_default_category&#093;<\/code> shortcode you can place in the details page template.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_shortcode( &#039;my_gd_default_category&#039;, &#039;my_gd_default_category_output&#039; );\nfunction my_gd_default_category_output() {\n\tglobal $gd_post;\n\n\tif ( empty( $gd_post-&gt;default_category ) ) {\n\t\treturn &#039;&#039;;\n\t}\n\n\t$taxonomy = $gd_post-&gt;post_type . &#039;category&#039;;\n\t$term_id  = (int) $gd_post-&gt;default_category;\n\t$term_ids = array_reverse( get_ancestors( $term_id, $taxonomy, &#039;taxonomy&#039; ) );\n\t$term_ids&#091;&#093; = $term_id;\n\n\t$links = array();\n\tforeach ( $term_ids as $id ) {\n\t\t$term = get_term( $id, $taxonomy );\n\t\tif ( $term &amp;&amp; ! is_wp_error( $term ) ) {\n\t\t\t$links&#091;&#093; = &#039;&lt;a href=&quot;&#039; . esc_url( get_term_link( $term ) ) . &#039;&quot;&gt;&#039; . esc_html( $term-&gt;name ) . &#039;&lt;\/a&gt;&#039;;\n\t\t}\n\t}\n\n\treturn &#039;&lt;div class=&quot;my-gd-default-category&quot;&gt;&#039; . implode( &#039; \/ &#039;, $links ) . &#039;&lt;\/div&gt;&#039;;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add it with the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a>. For finer changes to the block&#8217;s own output, the <code>geodir_details_taxonomies_output<\/code> filter receives the HTML for each taxonomy before it is shown. All the block options are in <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-widgets\/gd-single-taxonomies\/\">GD &gt; Single Taxonomies<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The GD &gt; Single Taxonomies block (&#091;gd_single_taxonomies&#093;) shows a listing&#8217;s categories and tags on the details page. Its options cover most changes without code: So this shows the categories only, with no label in front: Show only the main category with its parents Every listing has a default category, the main one used for its [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[213,422],"class_list":["post-2472","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-extensions-features","gd_placecategory-core-widgets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=2472"}],"version-history":[{"count":2,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2472\/revisions"}],"predecessor-version":[{"id":2726,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2472\/revisions\/2726"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2472"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2472"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}