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

Ambrosite Unlink Parent Categories

外掛說明

When activated, this plugin unlinks parent categories (that is, categories that have child categories underneath them in a hierarchy) in category menus and lists. It affects the output of wp_list_categories, as well as all plugins and widgets that use that function.

The plugin works by turning the parent category links into ‘dummy links’. That is, it replaces the href attribute on parent menu items with a ‘#’ (hash/pound) mark. A dummy link is just like a regular link, except that it leads back to the current page when clicked. The dummy links are given an inline style “cursor: default” to prevent the mouse pointer from turning into a hand when hovering over unlinked menu items.

The plugin is compatible with custom hierarchical taxonomies. To create a list of custom taxonomy terms, you must set the ‘taxonomy’ parameter of wp_list_categories. See the FAQ for more information.

Options

To configure the plugin options, go to the Settings menu in the WordPress admin panel and click on ‘Unlink Parent Categories’.

Use Dummy Links
If you uncheck this box, the plugin will unlink the parent categories by replacing the anchor tags with span tags. In some themes, this may cause problems with CSS styling. In order to fix this, you would need to add an additional selector to any rule that targets the anchor tags (see the FAQ for more information). If you are not experienced in writing CSS selectors, then it is strongly recommended to stick with dummy links.

Unlink Current Category
Unlink the current category, in addition to the parent categories.

Remove Link Titles
Remove the title attribute from the links (stops the tooltip from popping up when the mouse hovers over the menu items). This doesn’t have anything to do with unlinking parent categories, but it’s something a lot of people want, so I decided to include it.

Unlink Specific Categories
You can specify which categories you want unlinked, using a comma-separated list of category IDs (example: 3,7,31). If you want only the specified categories to be unlinked, then check the “Unlink specific categories only” box.

螢幕擷圖

  • The Unlink Parent Categories configuration page

安裝方式

  • Upload ambrosite-unlink-parent-categories.php to the /wp-content/plugins/ directory.
  • Activate the plugin through the Plugins menu in WordPress.
  • All parent categories in menus created with wp_list_categories will become unlinked as soon as the plugin is activated. It will also automatically unlink newly created parent categories as the category hierarchy is built.
  • Go to the Settings menu in the WordPress admin panel, and click on Unlink Parent categories to configure the plugin options.

常見問題集

I installed the plugin but it does not seem to be working. Why?

Unlink Parent Categories only affects the output of wp_list_categories. If your menu is not being generated by that functions, then the plugin will not work. If you want to test whether this is an issue with your menu, put the default ‘Categories’ widget into your sidebar. The Categories widget uses wp_list_categories, so if the parent categories are unlinked there, but not in your navigation menu, it means that your menu is not using wp_list_categories.

How can I use this plugin with custom taxonomies?

You must set the ‘taxonomy’ parameter of wp_list_categories in order to generate a list of custom taxonomy terms, as explained in the WordPress Codex:

https://codex.wordpress.org/Template_Tags/wp_list_categories#Display_Terms_in_a_custom_taxonomy

Once the taxonomy parameter is set, the plugin will unlink the parent terms in the list, just as it does with normal categories. You can also set a custom taxonomy for the default Categories widget, by putting the following code into functions.php:

function wc_args( $cat_args ) {
        $cat_args['taxonomy'] = 'my_taxonomy';
        return $cat_args;
}
add_filter('widget_categories_args', 'wc_args');
I do not want to use dummy links. How can I fix my menu styles when the parent categories are unlinked?

If you uncheck ‘Use Dummy Links’, the plugin will unlink the parent categories by replacing the anchor tags with span tags. In some themes, this may cause styling problems if there are CSS selectors targeting the anchor tags that have been removed. In order to fix this, you must add an additional selector to any rule that targets the anchor tags. The CSS rules are different for every theme, so I cannot give specific instructions. As a general example, if your menu styles look like this:

#menu li a {
    some styles ...
}

Then you would need to add an additional selector which targets the span:

`#menu li span,

menu li a {

some styles …
}`

使用者評論

2016 年 9 月 3 日
Sound like what I was searching for, but unfortunately the plugin is not working with current WP version and need to updated.
閱讀全部 1 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Ambrosite Unlink Parent Categories〉的開發相關工作。

參與者

變更記錄

1.0

  • Initial version.