{"id":16017,"date":"2011-12-13T16:08:47","date_gmt":"2011-12-13T16:08:47","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/category-template-hierarchy\/"},"modified":"2012-03-24T03:12:55","modified_gmt":"2012-03-24T03:12:55","slug":"category-template-hierarchy","status":"publish","type":"plugin","link":"https:\/\/lmo.wordpress.org\/plugins\/category-template-hierarchy\/","author":5817142,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.3.2.1","stable_tag":"trunk","tested":"3.3.2","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"Category Template Hierarchy","header_author":"Eddie Moya","header_description":"","assets_banners_color":"","last_updated":"2012-03-24 03:12:55","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/eddiemoya.com","header_plugin_uri":"http:\/\/eddiemoya.com\/","header_author_uri":"","rating":5,"author_block_rating":0,"active_installs":100,"downloads":19043,"num_ratings":3,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":{"1.3.2.1":"<p>Important Update: v1.3.2 did not save correctly - v1.3.2.1 includes: Bug Fixes: 1. Fixed missing &#039;category.php&#039; template, and fixed missing <code>category-{slug}.php<\/code> and <code>category-{id}<\/code> if category was neither parent or child.<\/p>","1.3.2":"<p>Important update: Bug Fixes: 1. Fixed missing &#039;category.php&#039; template, and fixed missing <code>category-{slug}.php<\/code> and <code>category-{id}<\/code> if category was neither parent or child.<\/p>","1.3.1":"<p>Important Update - Bug Fix: Missing &#039;category.php&#039; template fixed.<\/p>","1.3":"<p>Multiple Bug Fixes - [Fixed] global scope variables not being available in scope, and fixed bug where plugin was interfering with other non-category parts of the native Template Hierarchy. See changelog for details.<\/p>","1.2":"<p>Performance: Minor changes for <code>is_child_of_category_()<\/code> and <code>is_parent_of_category()<\/code>, no behavior change for either<\/p>","1.1.1":"<p>Bug fix &#039;print_pre&#039; error fixed.<\/p>","1.1":"<p>Upgrade immediately - New hierarchy, better, more reliable functionality.<\/p>","1.0.5":"<p>Please upgrade to 1.0.5 - Packaging problem fixed. Several basic bug fixes<\/p>","1.0.3":"<p>Please upgrade to 1.0.3. is_parent_category() and is_child_category() bugs fixed.<\/p>","1.0.2":"<p>Please upgrade to 1.0.2. Bugs in 1.0.1 and below may cause some category templates to map incorrectly.<\/p>","1.0.1":"<p>Please upgrade to 1.0.1. Bugs in 1.0 may cause a white screen.<\/p>"},"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"3"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.5"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[89,3956,975,1141,5889],"plugin_category":[43],"plugin_contributors":[81226],"plugin_business_model":[],"class_list":["post-16017","plugin","type-plugin","status-publish","hentry","plugin_tags-category","plugin_tags-hierarchy","plugin_tags-template","plugin_tags-theme","plugin_tags-theme-development","plugin_category-customization","plugin_contributors-eddiemoya","plugin_committers-eddiemoya"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/category-template-hierarchy.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Adds several new templates to the template hierarchy:<\/p>\n\n<ul>\n<li>child-of-category-{slug}.php<\/li>\n<li>category-{slug}.php<\/li>\n<li>child-of-category-{id}.php<\/li>\n<li>category-{term_id}.php<\/li>\n<li>parent-category.php<\/li>\n<li>child-category.php<\/li>\n<li>category.php<\/li>\n<li>archive.php<\/li>\n<li>index.php<\/li>\n<\/ul>\n\n<p>This greatly extends the native hierarchy of theme templates with regard to \ncategories. Theme developers can now easily create separate templates for \ncategories with children, with parents, and children of specific parents.<\/p>\n\n<p>Additionally makes available four (4) new conditional template tags:<\/p>\n\n<ul>\n<li>is_child_category();<\/li>\n<li>is_parent_category();<\/li>\n<li>is_child_of_category();<\/li>\n<li>is_parent_of_category();<\/li>\n<\/ul>\n\n<p>These functions are available for use in any theme or plugin as along as this \nplugin is active. For detailed documentation of these functions see the \n'Developer Notes: Conditional Tags' section of this readme file.<\/p>\n\n<p>Note: This plugin does not actually create parent-category.php, child-category.php \nor any of their related templates - rather it modifies the native <a href=\"http:\/\/codex.wordpress.org\/Template_Hierarchy\">template hierarchy<\/a>\nto allow theme developers to create specific templates for parent and child categories.<\/p>\n\n<h3>Developer Notes: Template Hierarchy<\/h3>\n\n<p>What follows are is the modified list of templates available for category pages. \nThese expand upon the native <a href=\"http:\/\/codex.wordpress.org\/Template_Hierarchy#Visual_Overview\">Template Hierarchy<\/a>.<\/p>\n\n<ul>\n<li>child-of-category-{slug}.php<\/li>\n<li>category-{slug}.php<\/li>\n<li>child-of-category-{id}.php<\/li>\n<li>category-{term_id}.php<\/li>\n<li>parent-category.php<\/li>\n<li>child-category.php<\/li>\n<li>category.php<\/li>\n<li>archive.php<\/li>\n<li>index.php<\/li>\n<\/ul>\n\n<p>The parent and child templates only become available if the current category is \na parent or a child respectively.<\/p>\n\n<p>Note: This plugin does not actually create parent-category.php, child-category.php \nor any of their related templates - rather it modifies the native <a href=\"http:\/\/codex.wordpress.org\/Template_Hierarchy\">template hierarchy<\/a>\nto allow theme developers to create specific templates for parent and child categories.<\/p>\n\n<h3>Developer Notes: Conditional Tags<\/h3>\n\n<p>With this plugin comes two additional <a href=\"http:\/\/codex.wordpress.org\/Conditional_Tags\">conditional tags<\/a> \nwhich behave much like any other in WordPress. In a similar fashion to how one \nmight use <a href=\"http:\/\/codex.wordpress.org\/Function_Reference\/is_category\">is_category()<\/a> or <a href=\"http:\/\/codex.wordpress.org\/Function_Reference\/cat_is_ancestor_of\">cat_is_ancestory_of()<\/a>, \ndevelopers may, with this plugin, use the following functions:<\/p>\n\n<ul>\n<li>is_parent_category()<\/li>\n<li>is_child_category()<\/li>\n<li>is_child_of_category()<\/li>\n<li>is_parent_of_category()<\/li>\n<\/ul>\n\n<h4>Description (part 1)<\/h4>\n\n<p>The <code>is_parent_category()<\/code> and <code>is_child_category()<\/code> conditional tags check if \nthe page being displayed (or passed as an argument) is of a category that has \nchildren (e.g. is a parent category)  has a parent (is a child), respectively. \nThey are boolean functions, meaning they return either TRUE or FALSE.<\/p>\n\n<h4>Usage<\/h4>\n\n<pre><code>&lt;?php is_parent_category( $category ); ?&gt;\n&lt;?php is_child_category( $category ); ?&gt;\n<\/code><\/pre>\n\n<h4>Parameters<\/h4>\n\n<p>$category (integer\/string\/object) (optional) Category ID, Category Slug, Category Object. Default: Current Category<\/p>\n\n<p>Note: Unlike is_category(), these functions will not take arrays of categories or category titles. I'll work on that. Sorry.<\/p>\n\n<h4>Return Values<\/h4>\n\n<p>(boolean) True on success, false on failure.<\/p>\n\n<h4>Examples<\/h4>\n\n<pre><code>is_parent_category()\nis_child_category()\n\/\/ When any parent\/child category archive page is being displayed\n\nis_parent_category( '9' );\nis_child_category( '9' );\n\/\/ When the archive page for Category 9 is being displayed AND its a parent\/child.\n\nis_parent_category( 'blue-cheese' );\nis_child_category( 'blue-cheese' );\n\/\/ When the archive page for the Category with Category Slug \"blue-cheese\" is being displayed AND its a parent\/child.\n<\/code><\/pre>\n\n<h4>Description (part 2)<\/h4>\n\n<p>The <code>is_parent_of_category()<\/code> and <code>is_child_of_category()<\/code> conditional tags \ncheck if a given category has a parent or child relationship to the current \ncategory or a category passed as its second parameter. They are \nboolean functions, meaning they return either TRUE or FALSE.<\/p>\n\n<h4>Usage<\/h4>\n\n<pre><code>&lt;?php is_parent_of_category($child_category, $parent_category, $direct_descendant); ?&gt;\n&lt;?php is_child_of_category($parent_category, $child_category, $direct_descendant);?&gt;\n<\/code><\/pre>\n\n<h4>Parameters<\/h4>\n\n<p>(object\/string\/integer) (required) Category of the would-be parent\/child respectively.\n(object\/string\/integer) (optional) Category of the would-be child\/parent respectfully. Default: Current Category\n(boolean) (optional) Whether or not the child should be a direct child of the parent. Default: True\n *<\/p>\n\n<h4>Return Values<\/h4>\n\n<p>(boolean) If the $direct_descendant flag set to true, function returns true if the child is a direct descendant of the parent, if child is no direct it will return false. If $direct_descendant is set to false it will return the same results as cat_is_ancestor_of().<\/p>\n\n<h4>Examples<\/h4>\n\n<p>The following function will return True...<\/p>\n\n<pre><code>is_child_of_category(0);\n\/\/ When a top level category is being displayed, zero being the parent id value for top level categories (e.g. categories with no parents).\n\nis_child_of_category(12);\n\/\/ When the current category is a direct child of the category whose ID is '12'.\n\nis_child_of_category('tv-shows')\n\/\/ When the current category is a direct child of the category with the slug 'tv-shows' (can also be category ID's).\n\nis_child_of_category('tv-shows', 'dexter');\n\/\/ When the category with slug 'dexter' is a direct child of the category with the slug 'tv-shows' (can also be category ID's). This may come in handy when manipulating categories while not in a category template.\n\nis_child_of_category('tv-shows', 'dexter', false);\n\/\/ When the category with the slug 'dexter' is a descendant of the category 'tv-shows' at any level. (uses cat_is_ancestor_of())\n\nis_child_of_category('tv-shows', null, false);\n\/\/ When the current category is a descendant of the 'tv-shows' category at any level. (uses cat_is_ancestor_of())\n\nis_parent_of_category(13);\n\/\/ When the current category is the direct parent of a category with the ID '13'.\n\nis_parent_of_category('dexter');\n\/\/ When the current category is the direct parent of the category with the slug 'dexter'.\n<\/code><\/pre>\n\n<h3>Backward Compatibility<\/h3>\n\n<p>The changes this plugin makes to the template hierarchy are significantly different \nfrom that in 1.0.5 and before. If you prefer to use that version please find it \nin the Older Versions in the WordPress plugins directory, it is tagged as 1.0.5.<\/p>\n\n<p>While I do not actively support to QA the older version, I would gladly take a \nlook at any future bugs that crop up and are reported.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>plugin-name.php<\/code> to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Do you have any Frequently Asked Questions?<\/dt>\n<dd><p>No.<\/p><\/dd>\n<dt>Why not?<\/dt>\n<dd><p>Because I only just recently released the plugin. I feel that I've done a decent \njob of documentation, so I can't guess what people may ask on this broadly \napplicable plugin.<\/p><\/dd>\n<dt>Can I ask you a question<\/dt>\n<dd><p>Please do! Feel free to ask on the tools provided right in the WordPress plugin \ndirectory, or on my website <a href=\"http:\/\/eddiemoya.com\/\">eddiemoya.com<\/a>.<\/p><\/dd>\n<dt>I liked the old hierarchy, with parent-category-{slug|id}.php and child-category-{slug|id}.php, where can I find that?<\/dt>\n<dd><p>The last version that used the old hierarchical model was 1.0.5, it was tagged \nas such and can be found in the WordPress directory by looking for Older Versions.<\/p><\/dd>\n<dt>You just said you have no frequently asked questions, wasn't that just a frequently asked question?<\/dt>\n<dd><p>Nope, no one has actually asked, just anticipating.<\/p><\/dd>\n<dt>What does the narwhal do at midnight?<\/dt>\n<dd><p>Bacon.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.3.2.1<\/h4>\n\n<ul>\n<li>Changes made in 1.3.2 were not properly checked in - this version is a re-release of 1.3.2 - apologies for the inconvenience.<\/li>\n<\/ul>\n\n<h4>1.3.2<\/h4>\n\n<ul>\n<li>Bug: [FIXED] <code>category-slug.php<\/code> and <code>category-id.php<\/code> were being excluded from the list of templates if the current category was neither a parent or a child.<\/li>\n<\/ul>\n\n<h4>1.3.1<\/h4>\n\n<ul>\n<li>Bug: [FIXED] Plugin was not finding 'category.php' when it was available.<\/li>\n<\/ul>\n\n<h4>1.3<\/h4>\n\n<ul>\n<li>Bug: [FIXED] Template Hierarchy manipulation was interfering with other parts of the native Template Hierarchy, now uses 'category_template' filter instead of 'template_redirect'.<\/li>\n<li>Bug: [FIXED] Child and Parent categories were not pulling $post and other normal globals into scope during the loop.<\/li>\n<li>Minor Logic Change: <code>is_child_of_category()<\/code> and <code>is_parent_of_category<\/code> now check specifically for <code>$category_parent-&gt;parent<\/code> and <code>$parent_category-&gt;term_id<\/code>, because the way it was before, honestly did not make much sense. <\/li>\n<\/ul>\n\n<h4>1.2<\/h4>\n\n<ul>\n<li>Performance enhancement: Added a simple check to <code>is_child_of_category_()<\/code> and <code>is_parent_of_category()<\/code> to return false if empty, before bothering to check if there are relationships. Prevents a PHP notice caused by attempting to get the property of a non-object - this would occur when either function is called and the page is not a category at all.<\/li>\n<\/ul>\n\n<h4>1.1.1<\/h4>\n\n<ul>\n<li>Fixed 'print_pre' bug caused by a debugging function which I failed to remove when debugging was completed.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>Completely restructured the hierarchical modifications this plugin creates.<\/li>\n<li>Added child-of-category-{slug}.php and child-of-category-{id}.php templates<\/li>\n<li>Added is_child_of_category() and is_parent_of_category() functions.<\/li>\n<li>Removed child-category-{slug}.php, child-category-{id}.php, parent-category-{slug}.php, parent-category-{id}.php because they aren't very useful and just dont fit into the cool crowd.<\/li>\n<li>Fixed all known bugs, and a few that were not known.<\/li>\n<\/ul>\n\n<h4>1.0.5<\/h4>\n\n<ul>\n<li>First actually stable release<\/li>\n<li>Packaging problem fixed - the plugin was incorrectly packaged, such that it failed on activation.<\/li>\n<li>Fixed several other very bad bugs<\/li>\n<\/ul>\n\n<h4>1.0.3<\/h4>\n\n<ul>\n<li>Fixed problems with the is_parent_category() and is_child_category() functions where they returned <code>null<\/code> if called from a non-category page. <\/li>\n<li>Removed the 'happy accident' wherein a category which is both a parent and a child results in a hierarchy based on parent-child-categroy.php. This reveals a more important problem which I plan to fix for version 1.1.<\/li>\n<li>Fixed a silly bug. Misspelled <code>is_numberic<\/code> rather than <code>is_numeric<\/code>.<\/li>\n<li>Removed unnecessary <code>exit<\/code>.<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial commit.<\/li>\n<\/ul>","raw_excerpt":"Adds parent-category.php, child-category.php, and child-category-{slug|id} templates to the hierarchy and conditional tags to match.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/16017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=16017"}],"author":[{"embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/eddiemoya"}],"wp:attachment":[{"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=16017"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=16017"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=16017"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=16017"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=16017"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/lmo.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=16017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}