{"id":5697,"date":"2009-06-12T04:33:55","date_gmt":"2009-06-12T04:33:55","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/peer-categories\/"},"modified":"2025-04-21T19:08:59","modified_gmt":"2025-04-21T19:08:59","slug":"peer-categories","status":"publish","type":"plugin","link":"https:\/\/srd.wordpress.org\/plugins\/peer-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":"Peer Categories","header_author":"Scott Reilly","header_description":"","assets_banners_color":"0074a2","last_updated":"2025-04-21 19:08:59","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\/peer-categories\/","header_author_uri":"https:\/\/coffee2code.com\/","rating":0,"author_block_rating":0,"active_installs":10,"downloads":7496,"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:55"},"1.1":{"tag":"1.1","author":"coffee2code","date":"2010-09-06 06:12:10"},"1.1.1":{"tag":"1.1.1","author":"coffee2code","date":"2011-02-24 19:30:41"},"1.1.2":{"tag":"1.1.2","author":"coffee2code","date":"2011-07-03 21:34:36"},"1.1.3":{"tag":"1.1.3","author":"coffee2code","date":"2011-12-11 07:04:41"},"1.1.4":{"tag":"1.1.4","author":"coffee2code","date":"2012-06-04 05:38:18"},"1.1.5":{"tag":"1.1.5","author":"coffee2code","date":"2012-12-09 08:30:45"},"2.0":{"tag":"2.0","author":"coffee2code","date":"2014-01-10 08:17:21"},"2.0.1":{"tag":"2.0.1","author":"coffee2code","date":"2014-09-01 05:45:09"},"2.0.2":{"tag":"2.0.2","author":"coffee2code","date":"2015-08-30 06:06:10"},"2.0.3":{"tag":"2.0.3","author":"coffee2code","date":"2016-04-13 22:56:52"},"2.0.4":{"tag":"2.0.4","author":"coffee2code","date":"2017-02-27 18:23:58"},"2.0.5":{"tag":"2.0.5","author":"coffee2code","date":"2018-06-30 05:26:48"},"2.1":{"tag":"2.1","author":"coffee2code","date":"2019-03-25 21:23:15"},"2.1.1":{"tag":"2.1.1","author":"coffee2code","date":"2019-06-22 06:39:46"},"2.1.2":{"tag":"2.1.2","author":"coffee2code","date":"2019-11-24 22:55:53"},"2.1.3":{"tag":"2.1.3","author":"coffee2code","date":"2020-05-30 07:27:22"},"2.1.4":{"tag":"2.1.4","author":"coffee2code","date":"2020-09-05 07:26:23"},"2.1.5":{"tag":"2.1.5","author":"coffee2code","date":"2021-04-18 06:44:21"},"2.2":{"tag":"2.2","author":"coffee2code","date":"2021-10-24 07:44:05"},"2.2.1":{"tag":"2.2.1","author":"coffee2code","date":"2023-08-22 18:08:45"},"2.3":{"tag":"2.3","author":"coffee2code","date":"2024-08-28 22:19:10"},"2.3.1":{"tag":"2.3.1","author":"coffee2code","date":"2025-04-21 19:08:59"}},"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, removed unnecessary functionality within <code>c2c_get_peer_categories()<\/code>, 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>peer_categories()<\/code>, <code>get_peer_categories_list()<\/code>, <code>get_peer_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: Added TODO.md file, 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: 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":976260,"resolution":"128x128","location":"assets","locale":""}},"assets_banners":{"banner-772x250.png":{"filename":"banner-772x250.png","revision":835972,"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":[89,2758,1089,34706,23068],"plugin_category":[57],"plugin_contributors":[78189],"plugin_business_model":[],"class_list":["post-5697","plugin","type-plugin","status-publish","hentry","plugin_tags-category","plugin_tags-coffee2code","plugin_tags-related-posts","plugin_tags-sibling","plugin_tags-the_category","plugin_category-taxonomy","plugin_contributors-coffee2code","plugin_committers-coffee2code"],"banners":{"banner":"https:\/\/ps.w.org\/peer-categories\/assets\/banner-772x250.png?rev=835972","banner_2x":false,"banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/peer-categories\/assets\/icon-128x128.png?rev=976260","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>This plugin provides a template tag which acts 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_peer_categories()<\/code> lists those categories <em>PLUS<\/em> any categories that are peer to those categories and <em>MINUS<\/em> categories that are parents to other assigned categories. Peer categories are categories that all share the same category parent.<\/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\" and \"Pumpkin\" to a post, <code>peer_categories()<\/code> would return a list that consists of: \"Bell Pepper\", \"Cucumber\", and \"Pumpkin\". Notice that since \"Fruiting\" was a parent to a directly assigned category, it and its peers are not included in the list. If only \"Fruiting\" were selected as a category, then \"Leafy\", \"Fruiting\", and \"Podded\" would have been listed.<\/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 peer categories: <code>&lt;?php c2c_peer_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_peer_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=\"https:\/\/example.com\/category\/fruiting\/bell-pepper\"&gt;Bell Pepper&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=\"https:\/\/example.com\/category\/fruiting\/cucumber\"&gt;Cucumber&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=\"https:\/\/example.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_peer_categories( ', ' ); ?&gt;&lt;\/ul&gt;<\/code><\/li>\n<\/ul>\n\n<p>Outputs something like:<\/p>\n\n<pre><code>&lt;a href=\"https:\/\/example.com\/category\/fruiting\/bell-pepper\"&gt;Bell Pepper&lt;\/a&gt;, &lt;a href=\"https:\/\/example.com\/category\/fruiting\/cucumber\"&gt;Cucumber&lt;\/a&gt;, &lt;a href=\"https:\/\/example.com\/category\/fruiting\/pumpkin\"&gt;Pumpkin&lt;\/a&gt;\n<\/code><\/pre>\n\n<p>Links: <a href=\"https:\/\/coffee2code.com\/wp-plugins\/peer-categories\/\">Plugin Homepage<\/a> | <a href=\"https:\/\/wordpress.org\/plugins\/peer-categories\/\">Plugin Directory Page<\/a> | <a href=\"https:\/\/github.com\/coffee2code\/peer-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\/peer-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_peer_categories()<\/code>          : Outputs the peer categories.<\/li>\n<li><code>c2c_get_peer_categories_list()<\/code> : Returns the list of peer categories.<\/li>\n<li><code>c2c_get_peer_categories()<\/code>      : Returns the list of peer 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_peer_categories<\/code> <em>(action)<\/em>, <code>c2c_get_peer_categories_list<\/code>, <code>c2c_get_peer_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_peer_categories_list<\/code> <em>(filter)<\/em> :\nCustomizes the return value of the <code>c2c_peer_categories_list()<\/code> function.<\/li>\n<li><code>c2c_get_peer_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_peer_categories_list' to filter peer category listing<\/li>\n<li>Use the template tag <code>&lt;?php c2c_peer_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%27c2c_peer_categories%28%29%27%20listing%3F'><h3>Why isn't an assigned category for the post showing up in the 'c2c_peer_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. Only peers to the lowest-level assigned categories are considered.<\/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\/peer-categories\/\">plugin's GitHub repository<\/a>.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>2.3.1 (2025-04-21)<\/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, removes unnecessary functionality within <code>c2c_get_peer_categories()<\/code>, 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: Remove behavior of <code>c2c_get_peer_categories()<\/code> potentially returning all top-level categories<\/li>\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: Add missing inline documentation for a filter argument<\/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>Change: Prevent PHP warnings due to missing core-related generated files<\/li>\n<li>New: Add tests for <code>c2c_peer_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\/peer-categories\/blob\/master\/CHANGELOG.md\">CHANGELOG.md<\/a>.<\/em><\/p>","raw_excerpt":"List the categories that are peer (i.e. share the same category parent) to all lowest-level assigned categories for the specified post.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/5697","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=5697"}],"wp:attachment":[{"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=5697"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=5697"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=5697"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=5697"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=5697"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/srd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=5697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}