10+
April 21, 2025
June 12, 2009
This plugin provides a template tag which acts as a modified version of WordPress’s built-in template tag, the_category(). the_category() lists all categories directly assigned to the specified post. c2c_parentless_categories() lists those categories, except for categories that are parents to other assigned categories.
For example, assume your category structure is hierarchical and looks like this:
Vegetables
|-- Leafy
| |-- Broccoli
| |-- Bok Choy
| |-- Celery
|-- Fruiting
| |-- Bell Pepper
| |-- Cucumber
| |-- Pumpkin
|-- Podded
| |-- Chickpea
| |-- Lentil
| |-- Soybean
If you directly assigned the categories “Fruiting”, “Cucumber”, and “Pumpkin” to a post, c2c_parentless_categories() 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.
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: <?php c2c_parentless_categories( ',' ); ?>.
As with categories listed via the_category(), categories that are listed are presented as links to the respective category’s archive page.
Example usage (based on preceding example):
<?php c2c_parentless_categories(); ?>Outputs something like:
<ul><li><a href="http://yourblog.com/category/fruiting/cucumber">Cucumber</a></li>
<li><a href="http://yourblog.com/category/fruiting/pumpkin">Pumpkin</a></li></ul>
<?php c2c_parentless_categories( ',' ); ?></ul>Outputs something like:
<a href="http://yourblog.com/category/fruiting/cucumber">Cucumber</a>, <a href="http://yourblog.com/category/fruiting/pumpkin">Pumpkin</a>
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the template tags and hooks provided by the plugin.
As an overview, these are the template tags provided by the plugin:
c2c_parentless_categories() : Outputs the parentless categories.c2c_get_parentless_categories_list() : Returns the list of parentless categories.c2c_get_parentless_categories() : Returns the list of parentless categories for the specified post.These are the hooks provided by the plugin:
c2c_parentless_categories (action), c2c_get_parentless_categories_list, c2c_get_parentless_categories (filters) :c2c_parentless_categories_list (filter) :c2c_parentless_categories_list() function.c2c_get_parentless_categories_omit_ancestors (filter) :/wp-content/plugins/).<?php c2c_parentless_categories(); ?> in a theme template somewhere inside “the loop”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.
Yes. The tests are not packaged in the release .zip file or included in plugins.svn.wordpress.org, but can be found in the plugin’s GitHub repository.
Highlights:
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).
Details:
.gitignore filecomposer.json for PHPUnit Polyfill dependencybootstrap.phpc2c_parentless_categories()Full changelog is available in CHANGELOG.md.
| Version | Download | Type |
|---|---|---|
| 2.3.1 | Download | Stable |
| 2.3 | Download | Stable |
| 2.2.1 | Download | Stable |
| 2.2 | Download | Stable |
| 2.1.5 | Download | Stable |
| 2.1.4 | Download | Stable |
| 2.1.3 | Download | Stable |
| 2.1.2 | Download | Stable |
| 2.1.1 | Download | Stable |
| 2.1 | Download | Stable |
| 2.0.5 | Download | Stable |
| 2.0.4 | Download | Stable |
| 2.0.3 | Download | Stable |
| 2.0.2 | Download | Stable |
| 2.0.1 | Download | Stable |
| 2.0 | Download | Stable |
| 1.1.5 | Download | Stable |
| 1.1.4 | Download | Stable |
| 1.1.3 | Download | Stable |
| 1.1.2 | Download | Stable |
| 1.1.1 | Download | Stable |
| 1.1 | Download | Stable |
| 1.0 | Download | Stable |
| Development | Download | Trunk |