這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

Elevate Parent Category Template

描述

This plugin provides functions to retrieve the parent category of any particular post should it be assigned to a sub category of that parent category.

Using this feature, the plugin is also able to modify the WordPress Loop to redirect any category page generation to the parent category. This is especially useful when theme developers want to be able to specify category-x.php templates and have all related posts, be it those assigned to the category or the sub categories use that template for page generation.

So for example the current category structure is as follows.

  • Main Category (has category-x.php template)
    • Sub Category 1
    • Sub Category 2

A post is assigned to “Sub Category 2”.

When the post is requested the plugin will automatically detect if it has a parent category. If so, it will modify the WP variables to set the current category as the parent category and add a new variable stating the actual category of the post. This affects the WordPress Loop to category-x.php template defined for the parent

Usable Commands for Theme Developers

The PHP commands for theme developers to use are pretty straight forward.

get_category_child() returns the current post child category ID.

is_parent() checks if the current post is at the parent category.

get_category_title($id) gets the title of the category that is $id.

get_category_parent() returns the current post’s parent category ID.

安裝

  1. Upload elevate-parent-category-template.php into your plugins folder.
  2. Activate and you’re done.

評價

There are no reviews for this plugin.

貢獻者及開發者

“Elevate Parent Category Template” 是一個開源的軟體。以下的人對這個外掛作出了貢獻。

貢獻者