{"id":5695,"date":"2009-06-12T04:33:13","date_gmt":"2009-06-12T04:33:13","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/parentless-categories\/"},"modified":"2025-04-21T19:03:26","modified_gmt":"2025-04-21T19:03:26","slug":"parentless-categories","status":"publish","type":"plugin","link":"https:\/\/srd.wordpress.org\/plugins\/parentless-categories\/","author":3606,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"2.3.1","stable_tag":"2.3.1","tested":"6.8.5","requires":"4.6","requires_php":"","requires_plugins":null,"header_name":"Parentless Categories","header_author":"Scott Reilly","header_description":"","assets_banners_color":"0074a2","last_updated":"2025-04-21 19:03:26","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_s-xclick&hosted_button_id=6ARCFJ9TX3522","header_plugin_uri":"https:\/\/coffee2code.com\/wp-plugins\/parentless-categories\/","header_author_uri":"https:\/\/coffee2code.com\/","rating":0,"author_block_rating":0,"active_installs":10,"downloads":6046,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0":{"tag":"1.0","author":"coffee2code","date":"2009-06-12 04:33:13"},"1.1":{"tag":"1.1","author":"coffee2code","date":"2010-09-06 06:06:55"},"1.1.1":{"tag":"1.1.1","author":"coffee2code","date":"2011-02-24 19:27:45"},"1.1.2":{"tag":"1.1.2","author":"coffee2code","date":"2011-07-15 14:25:54"},"1.1.3":{"tag":"1.1.3","author":"coffee2code","date":"2011-12-11 07:03:47"},"1.1.4":{"tag":"1.1.4","author":"coffee2code","date":"2012-06-04 05:37:24"},"1.1.5":{"tag":"1.1.5","author":"coffee2code","date":"2012-12-09 08:29:54"},"2.0":{"tag":"2.0","author":"coffee2code","date":"2014-01-10 08:14:18"},"2.0.1":{"tag":"2.0.1","author":"coffee2code","date":"2014-08-31 07:01:32"},"2.0.2":{"tag":"2.0.2","author":"coffee2code","date":"2015-08-30 06:05:24"},"2.0.3":{"tag":"2.0.3","author":"coffee2code","date":"2016-04-13 22:57:58"},"2.0.4":{"tag":"2.0.4","author":"coffee2code","date":"2017-02-27 18:11:04"},"2.0.5":{"tag":"2.0.5","author":"coffee2code","date":"2018-06-30 05:05:46"},"2.1":{"tag":"2.1","author":"coffee2code","date":"2019-03-25 05:49:00"},"2.1.1":{"tag":"2.1.1","author":"coffee2code","date":"2019-06-24 05:10:22"},"2.1.2":{"tag":"2.1.2","author":"coffee2code","date":"2019-11-24 07:39:17"},"2.1.3":{"tag":"2.1.3","author":"coffee2code","date":"2020-05-29 08:07:27"},"2.1.4":{"tag":"2.1.4","author":"coffee2code","date":"2020-09-05 07:01:30"},"2.1.5":{"tag":"2.1.5","author":"coffee2code","date":"2021-04-17 07:13:53"},"2.2":{"tag":"2.2","author":"coffee2code","date":"2021-10-23 07:30:27"},"2.2.1":{"tag":"2.2.1","author":"coffee2code","date":"2023-08-22 18:07:59"},"2.3":{"tag":"2.3","author":"coffee2code","date":"2024-08-28 22:04:19"},"2.3.1":{"tag":"2.3.1","author":"coffee2code","date":"2025-04-21 19:03:26"}},"upgrade_notice":{"2.3.1":"<p>Trivial update: noted compatibility through WP 6.8+ and PHP 8.3+, and updated copyright date (2025)<\/p>","2.3":"<p>Minor update: prevented translations from containing unintended markup, noted compatibility through WP 6.6+, removed unit tests from release packaging, and updated copyright date (2024)<\/p>","2.2.1":"<p>Trivial update: noted compatibility through WP 6.3+ and updated copyright date (2023)<\/p>","2.2":"<p>Minor update: removed support for long-deprecated functions (<code>parentless_categories()<\/code>, <code>get_parentless_categories_list()<\/code>, <code>get_parentless_categories()<\/code>), added DEVELOPER-DOCS.md, noted compatibility through WP 5.8+, and minor reorganization and tweaks to unit tests<\/p>","2.1.5":"<p>Trivial update: noted compatibility through WP 5.7+ and updated copyright date (2021)<\/p>","2.1.4":"<p>Trivial update: Restructured unit test file structure and noted compatibility through WP 5.5+.<\/p>","2.1.3":"<p>Trivial update: Reworded plugin description, added TODO.md file, fixed some documentation typos, updated a few URLs to be HTTPS, and noted compatibility through WP 5.4+<\/p>","2.1.2":"<p>Trivial update: noted compatibility through WP 5.3+ and updated copyright date (2020)<\/p>","2.1.1":"<p>Trivial update: modernized unit tests and noted compatibility through WP 5.2+<\/p>","2.1":"<p>Minor update: checked for post type&#039;s support of categories, created CHANGELOG.md to store historical changelog outside of readme.txt, noted compatibility through WP 5.1+, updated copyright date (2019), and minor code improvements<\/p>","2.0.5":"<p>Trivial update: noted compatibility through WP 4.9+, added README.md for GitHub, updated copyright date (2018), and other minor changes<\/p>","2.0.4":"<p>Recommended minor update: fixed PHP warning in WP 4.7 due to function deprecation, noted compatibility through WP 4.7+, updated copyright date<\/p>","2.0.3":"<p>Trivial update: noted compatibility through WP 4.4+ and updated copyright date (2016)<\/p>","2.0.2":"<p>Trivial update: noted compatibility through WP 4.1+ and updated copyright date<\/p>","2.0.1":"<p>Trivial update: noted compatibility through WP 4.0+; added plugin icon.<\/p>","2.0":"<p>Major update: deprecated all existing functions and filters in favor of &#039;c2c_&#039; prepended versions; added unit tests; noted compatibility is now only for WP 3.6-3.8+<\/p>","1.1.5":"<p>Trivial update: noted compatibility through WP 3.5+<\/p>","1.1.4":"<p>Trivial update: noted compatibility through WP 3.4+; explicitly stated license<\/p>","1.1.3":"<p>Trivial update: noted compatibility through WP 3.3+<\/p>","1.1.2":"<p>Trivial update: noted compatibility through WP 3.2+<\/p>","1.1.1":"<p>Trivial update: documentation tweaks; noted compatibility with WP 3.1+ and updated copyright date.<\/p>","1.1":"<p>Minor update. Highlights: miscellaneous non-functionality tweaks; verified WP 3.0 compatibility.<\/p>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":976009,"resolution":"128x128","location":"assets","locale":""}},"assets_banners":{"banner-772x250.png":{"filename":"banner-772x250.png","revision":835971,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.1","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","2.0","2.0.1","2.0.2","2.0.3","2.0.4","2.0.5","2.1","2.1.1","2.1.2","2.1.3","2.1.4","2.1.5","2.2","2.2.1","2.3","2.3.1"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[610,89,2758,245,23068],"plugin_category":[57],"plugin_contributors":[78189],"plugin_business_model":[],"class_list":["post-5695","plugin","type-plugin","status-publish","hentry","plugin_tags-categories","plugin_tags-category","plugin_tags-coffee2code","plugin_tags-list","plugin_tags-the_category","plugin_category-taxonomy","plugin_contributors-coffee2code","plugin_committers-coffee2code"],"banners":{"banner":"https:\/\/ps.w.org\/parentless-categories\/assets\/banner-772x250.png?rev=835971","banner_2x":false,"banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/parentless-categories\/assets\/icon-128x128.png?rev=976009","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>This plugin provides a template tag which acts as a modified version of WordPress's built-in template tag, <code>the_category()<\/code>. <code>the_category()<\/code> lists all categories directly assigned to the specified post. <code>c2c_parentless_categories()<\/code> lists those categories, except for categories that are parents to other assigned categories.<\/p>\n\n<p>For example, assume your category structure is hierarchical and looks like this:<\/p>\n\n<pre><code>Vegetables\n|-- Leafy\n|   |-- Broccoli\n|   |-- Bok Choy\n|   |-- Celery\n|-- Fruiting\n|   |-- Bell Pepper\n|   |-- Cucumber\n|   |-- Pumpkin\n|-- Podded\n|   |-- Chickpea\n|   |-- Lentil\n|   |-- Soybean\n<\/code><\/pre>\n\n<p>If you directly assigned the categories \"Fruiting\", \"Cucumber\", and \"Pumpkin\" to a post, <code>c2c_parentless_categories()<\/code> would return a list that consists of: \"Cucumber\", and \"Pumpkin\". Notice that since \"Fruiting\" was a parent to a directly assigned category, it is not included in the list.<\/p>\n\n<p>By default, categories are listed as an HTML list. The first argument to the template tag allows you to define a custom separator, e.g. to have a simple comma-separated list of categories: <code>&lt;?php c2c_parentless_categories( ',' ); ?&gt;<\/code>.<\/p>\n\n<p>As with categories listed via <code>the_category()<\/code>, categories that are listed are presented as links to the respective category's archive page.<\/p>\n\n<p>Example usage (based on preceding example):<\/p>\n\n<ul>\n<li><code>&lt;?php c2c_parentless_categories(); ?&gt;<\/code><\/li>\n<\/ul>\n\n<p>Outputs something like:<\/p>\n\n<pre><code>&lt;ul&gt;&lt;li&gt;&lt;a href=\"http:\/\/yourblog.com\/category\/fruiting\/cucumber\"&gt;Cucumber&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=\"http:\/\/yourblog.com\/category\/fruiting\/pumpkin\"&gt;Pumpkin&lt;\/a&gt;&lt;\/li&gt;&lt;\/ul&gt;\n<\/code><\/pre>\n\n<ul>\n<li><code>&lt;?php c2c_parentless_categories( ',' ); ?&gt;&lt;\/ul&gt;<\/code><\/li>\n<\/ul>\n\n<p>Outputs something like:<\/p>\n\n<pre><code>&lt;a href=\"http:\/\/yourblog.com\/category\/fruiting\/cucumber\"&gt;Cucumber&lt;\/a&gt;, &lt;a href=\"http:\/\/yourblog.com\/category\/fruiting\/pumpkin\"&gt;Pumpkin&lt;\/a&gt;\n<\/code><\/pre>\n\n<p>Links: <a href=\"https:\/\/coffee2code.com\/wp-plugins\/parentless-categories\/\">Plugin Homepage<\/a> | <a href=\"https:\/\/wordpress.org\/plugins\/parentless-categories\/\">Plugin Directory Page<\/a> | <a href=\"https:\/\/github.com\/coffee2code\/parentless-categories\/\">GitHub<\/a> | <a href=\"https:\/\/coffee2code.com\">Author Homepage<\/a><\/p>\n\n<h3>Developer Documentation<\/h3>\n\n<p>Developer documentation can be found in <a href=\"https:\/\/github.com\/coffee2code\/parentless-categories\/blob\/master\/DEVELOPER-DOCS.md\">DEVELOPER-DOCS.md<\/a>. That documentation covers the template tags and hooks provided by the plugin.<\/p>\n\n<p>As an overview, these are the template tags provided by the plugin:<\/p>\n\n<ul>\n<li><code>c2c_parentless_categories()<\/code>          : Outputs the parentless categories.<\/li>\n<li><code>c2c_get_parentless_categories_list()<\/code> : Returns the list of parentless categories.<\/li>\n<li><code>c2c_get_parentless_categories()<\/code>      : Returns the list of parentless categories for the specified post.<\/li>\n<\/ul>\n\n<p>These are the hooks provided by the plugin:<\/p>\n\n<ul>\n<li><code>c2c_parentless_categories<\/code> <em>(action)<\/em>, <code>c2c_get_parentless_categories_list<\/code>, <code>c2c_get_parentless_categories<\/code> <em>(filters)<\/em> :\nAllows for an alternative approach to safely invoke each of the identically named functions in such a way that if the plugin were deactivated or deleted, then your calls to the functions won't cause errors on your site.<\/li>\n<li><code>c2c_parentless_categories_list<\/code> <em>(filter)<\/em> :\nCustomizes the return value of the <code>c2c_parentless_categories_list()<\/code> function.<\/li>\n<li><code>c2c_get_parentless_categories_omit_ancestors<\/code> <em>(filter)<\/em> :\nCustomizes the function argument indicating if ancestor categories of all directly assigned categories (even if directly assigned themselves) should be omitted from the return list of categories.<\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Install via the built-in WordPress plugin installer. Or install the plugin code inside the plugins directory for your site (typically <code>\/wp-content\/plugins\/<\/code>).<\/li>\n<li>Activate the plugin through the 'Plugins' admin menu in WordPress<\/li>\n<li>Optional: Add filters for 'c2c_parentless_categories_list' to filter parentless category listing<\/li>\n<li>Use the template tag <code>&lt;?php c2c_parentless_categories(); ?&gt;<\/code> in a theme template somewhere inside \"the loop\"<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='why%20isn%27t%20an%20assigned%20category%20for%20the%20post%20showing%20up%20in%20the%20%60c2c_parentless_categories%28%29%60%20listing%3F'><h3>Why isn't an assigned category for the post showing up in the `c2c_parentless_categories()` listing?<\/h3><\/dt>\n<dd><p>If an assigned category is the parent for one or more other assigned categories for the post, then the category parent is not included in the listing.<\/p><\/dd>\n<dt id='does%20this%20plugin%20have%20unit%20tests%3F'><h3>Does this plugin have unit tests?<\/h3><\/dt>\n<dd><p>Yes. The tests are not packaged in the release .zip file or included in plugins.svn.wordpress.org, but can be found in the <a href=\"https:\/\/github.com\/coffee2code\/parentless-categories\/\">plugin's GitHub repository<\/a>.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>2.3.1 (2025-04-20)<\/h4>\n\n<ul>\n<li>Change: Note compatibility through WP 6.8+<\/li>\n<li>Change: Note compatibility through PHP 8.3+<\/li>\n<li>Change: Update copyright date (2025)<\/li>\n<li>Unit tests:\n\n<ul>\n<li>Change: Explicitly define return type for overridden method<\/li>\n<\/ul><\/li>\n<\/ul>\n\n<h4>2.3 (2024-08-28)<\/h4>\n\n<p>Highlights:<\/p>\n\n<p>This minor release prevents translations from containing unintended markup, notes compatibility through WP 6.6+, removes unit tests from release packaging, and updates copyright date (2024).<\/p>\n\n<p>Details:<\/p>\n\n<ul>\n<li>Change: Prevent translations from containing unintended markup<\/li>\n<li>Change: Add missing inline comment for translators<\/li>\n<li>Change: Note compatibility through WP 6.6+<\/li>\n<li>Change: Update copyright date (2024)<\/li>\n<li>Change: Remove development and testing-related files from release packaging<\/li>\n<li>New: Add <code>.gitignore<\/code> file<\/li>\n<li>Unit tests:\n\n<ul>\n<li>Allow tests to run against current versions of WordPress<\/li>\n<li>New: Add <code>composer.json<\/code> for PHPUnit Polyfill dependency<\/li>\n<li>Hardening: Prevent direct web access to <code>bootstrap.php<\/code><\/li>\n<li>Change: In bootstrap, store path to plugin directory in a constant<\/li>\n<li>New: Add tests for <code>c2c_parentless_categories()<\/code><\/li>\n<li>New: Add tests for function invocation filters<\/li>\n<li>Change: Tweak some inline comment formatting<\/li>\n<\/ul><\/li>\n<\/ul>\n\n<h4>2.2.1 (2023-05-20)<\/h4>\n\n<ul>\n<li>Change: Note compatibility through WP 6.3+<\/li>\n<li>Change: Update copyright date (2023)<\/li>\n<\/ul>\n\n<p><em>Full changelog is available in <a href=\"https:\/\/github.com\/coffee2code\/parentless-categories\/blob\/master\/CHANGELOG.md\">CHANGELOG.md<\/a>.<\/em><\/p>","raw_excerpt":"Provides a template tag like the_category() to list categories assigned to a post except those that have a child category also assigned to the post.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/5695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"author":[{"embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/users\/3606"}],"replies":[{"embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=5695"}],"wp:attachment":[{"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=5695"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=5695"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=5695"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=5695"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=5695"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=5695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}