Title: Hikari Category Permalink
Author: shidouhikari
Published: <strong>2010 年 6 月 23 日</strong>
Last modified: 2010 年 10 月 17 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/hikari-category-permalink.svg)

# Hikari Category Permalink

 作者：[shidouhikari](https://profiles.wordpress.org/shidouhikari/)

[下载](https://downloads.wordpress.org/plugin/hikari-category-permalink.1.00.08.zip)

 * [详情](https://cn.wordpress.org/plugins/hikari-category-permalink/#description)
 * [评价](https://cn.wordpress.org/plugins/hikari-category-permalink/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/hikari-category-permalink/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/hikari-category-permalink/#developers)

 [支持](https://wordpress.org/support/plugin/hikari-category-permalink/)

## 描述

WordPress 3.0 comes with a new filter that lets us customize what is used for each
permalink structure tag, other than WordPress default.

One of these permalink structure tags is `%category%`. By default, WordPress always
use the category with lowest ID, making `%category%` impractical for SEO optimization.

**Hikari Category Permalink** allows post authors to choose among each post’s categories,
which of them is used in that post permalink, giving much more flexibility and power
to permalinks.

This plugin is a fork of [Dmytro’s sCategory Permalink](https://wordpress.org/extend/plugins/scategory-permalink/).
It has all original features and is compatible with original options, while being
more stable and simple, and also fixes 2 recurring bugs.

#### Features

 * You can choose for each post separately, which category is used in its `%category%`
   permalink.
 * Posts without a category set to be used in permalink behave as WordPress default,(
   which currently is) the one with lowest ID is used
 * Posts with a category set have it used
 * In post edit page, where you set the post’s categories, there’s a new feature
   allowing you to choose which category will be used in permalink
 * No rewrite rules tweaks are done, making the plugin much simpler and bug free
 * If you already used sCategory Permalink, you can safely deactivate it and replace
   by **Hikari Category Permalink**, all your category permalinks will be used

## 屏幕截图

 * [[
 * Category metabox when a new post is created
 * [[
 * Category metabox when categories are already selected, but no permalink set yet
 * [[
 * Permalink selection feature appears when mouse hovers over it
 * [[
 * When permalink is selected, category becomes bold

## 安装

**Hikari Category Permalink** requires at least _WordPress 3.0_ and _PHP5_ to work.
It has backward compatibily for WordPress 2.8 and 2.9, but they are deprecated and
I don’t support them officially. Setting category permalink also requires _JavaScript_
enabled.

If you have Dmytro’s sCategory Permalink plugin installed, first deactivate it. **
Hikari Category Permalink** doesn’t conflict with the legacy plugin, but I don’t
recommend keeping both activated.

Once you are ready to install, you can use the built in installer and upgrader, 
or you can install the plugin manually.

 1. Download the zip file, upload it to your server and extract all its content to 
    your `/wp-content/plugins` folder. Make sure the plugin has its own folder (for
    exemple `/wp-content/plugins/hikari-category-permalink/`).
 2. Activate the plugin through the ‘Plugins’ menu in WordPress admin page.
 3. Go to Settings > Permalink, select “Custom Structure” and set any structure you’d
    like, using the `%category%` tag. For an exemple, you can use `/%category%/%post_id%/%
    postname%/`.
 4. There’s no option to be configured. Just try to edit any existing post or create
    a new one.
 5. When you hover mouse in a category in the “Categories box”, you’ll see a blue “
    Permalink” text appear on the right of the hovered category, just click on that
    text to set that category to be used in this post permalink. (You need JavaScript
    enabled to see the “Permalink” text appear)

#### Upgrading

If you have to upgrade manually, simply delete `hikari-category-permalink` folder
and follow installation steps again.

If you are using Dmytro’s sCategory Permalink plugin, just deactivate it and activate
Hikari Category Permalink.
 And once the upgrade is done, _if you are using WordPress
3.0 or above_, go to Settings > Permalink and replace legacy `%scategory%` tag to
stantard `%category%`!

#### Uninstalling

To uninstall just deactivate the plugin, or delete its folder.

There’s no wp_options option stored, posts category permalinks are stored as postmeta.
Currently there’s no automatic way to delete these postmeta if you don’t need them
anymore, this feature will be added in a future release.

## 常见问题

  What happens if I don’t use the `%category%` tag in my permalink structure?

You still can set category permalinks when creating and editing posts, but their
permalinks won’t have any category on them. When you decide to use `%category%` 
in your permalinks, saved categories will start being used.

  And what happens if I used it, but then remove the tag from my structure?

Your posts URLs will of course change, and not have category on them anymore. But
postmeta will remain saved and you’ll still be able to set them, and when you decide
to use the `%category%` tag again they’ll be used.

  What happens for posts that have no category permalink set?

Hikari Category Permalink just does nothing and send the permastruct back to WordPress
to deal with it in its default. WordPress default is use the category with lowest
ID.

  I’ve read that WordPress is inefficient when only string tags are used in posts
permalink, how does your plugin deals with it?

It’s inefficient because WordPress generates and parses permalinks dynamically, 
they aren’t stored, and to parse it uses general expressions and database queries.
If you only have string tags in posts permalinks, there’s no way for WordPress to
distinguish posts from pages, and then it must use slower methods to identify a 
post.

**Hikari Category Permalink** uses the standard `%category%` tag and doesn’t require
any rewrite rules tweaking, all its tweaks are in permalink creation (`get_permalink()`
function) and not in parsing, so your permalink structure has the same weakness 
it would have if the plugin wasn’t being used. I suggest adding an integer tag somewhere
in the structure (begining, middle or end, if you use more than 1 string tag I suggest
adding an int tag between them). My prefered one is `%post_id%`, because its meaning
is directly related to the post, and you have quick view to a post ID when you can
see its permalink.

  Why did you fork Dmytro’s sCategory Permalink?

sCategory Permalink is a great plugin, it was original, unique, and pionner. For
long we were in need of a category-in-permalink solution than the simple the-one-
with-lowest-ID WordPress offers. Dmytro was able to imagine a much better solution
and implement it.

But the plugin was bugged, it’s in v0.6.2 for a long time, and I was still using
v0.3.0, because any version above it was generating 404 for me in any post, while
v0.3.0 generates 404 when I use multipaged comments. Dmytro offered the plugin for
free and made it almost perfect, but it wasn’t being supported anymore and he didn’t
answer my contact attempts, so I decided to fix it.

I wasn’t able to fix the original bugs, but discovered that with a new filter inside`
get_permalink()`, the code with original bugs wouldn’t be needed anymore, the plugin
would be much simpler to tweak WordPress and permalink generation would be much 
more flexible. I opened a ticket in WordPress trac requesting the new filter, and
it was added to 3.0! 😀

Since I can’t contact Dmytro, I just forked the plugin and enhanced it.

  I’m currently using Dmytro’s sCategory Permalink, can I safely upgrade to Hikari
Category Permalink?

Yes, I did that 😛

It uses the same postmeta, so all your existing category permalinks will be used,
and new ones will use the same name, all simple. And with the advantage of 404 errors
being totally gone, since Hikari Category Permalink doesn’t touch rewrite rules!
😀

And one more thing, once the upgrade is done, _if you are using WordPress 3.0 or
above_, go to Settings > Permalink and replace legacy `%scategory%` tag to stantard`%
category%`!

  Why your plugin doesn’t support WordPress 2.9?

It indeed supports and I’ve been using in it, even 2.8 may work. But when used in
WordPress _below_ 3.0, the legacy `%scategory%` tag **must** be used, standard `%
category%` **doesn’t** work, and therefore 404 error when multipages comments are
used may occur. I just hacked my WordPress core and added the filter that only 3.0
has natively, but I won’t explain other people how to do it in 2.9 and won’t support
any bug on it, I only support Hikari Category Permalink in WordPress 3.0 and above
🙂

## 评价

![](https://secure.gravatar.com/avatar/b35a8a27d3579b9397f4167e697b342300d5edb61ccd5ab68cfc606b40e67ea9?
s=60&d=retro&r=g)

### 󠀁[Does what it says on the tin.](https://wordpress.org/support/topic/does-what-it-says-on-the-tin-287/)󠁿

 [vincentjflorio](https://profiles.wordpress.org/vincentjflorio/) 2017 年 12 月 
7 日

I installed it, visited my post, hovered over the category names on the right sidebar
on the post edit screen, clicked the word “Permalink,” the category name went bold,
I saved the post, and when the page refreshed my URL had changed. I didn’t even 
think about this as a use case but that was a quick and easy way to just totally
make it a non-issue. Thanks!

![](https://secure.gravatar.com/avatar/748d230752853ef5d59025b2fc1bb84aeaf8b8262134d76e812e480fd891e371?
s=60&d=retro&r=g)

### 󠀁[Excellent](https://wordpress.org/support/topic/excellent-5385/)󠁿

 [jiousept](https://profiles.wordpress.org/jiousept/) 2017 年 9 月 26 日

Simple, efficient and still works in Wordpress 4.8.1

![](https://secure.gravatar.com/avatar/df0969918a0013cbec63345a352bf59374e8680efa24937d7559eedd0d334576?
s=60&d=retro&r=g)

### 󠀁[Seems to work on 4.3](https://wordpress.org/support/topic/seems-to-work-on-43/)󠁿

 [edaniels](https://profiles.wordpress.org/edaniels/) 2016 年 9 月 3 日

Just downloaded, seems to work on 4.3

 [ 阅读所有5条评价 ](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/)

## 贡献者及开发者

「Hikari Category Permalink」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ shidouhikari ](https://profiles.wordpress.org/shidouhikari/)

[帮助将「Hikari Category Permalink」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/hikari-category-permalink)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/hikari-category-permalink/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/hikari-category-permalink/)，或通过
[RSS](https://plugins.trac.wordpress.org/log/hikari-category-permalink/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/hikari-category-permalink/)。

## 更新日志

#### 1.00.08

 * It seems WordPress is executing an action in unexpected places, that’s making
   the plugin delete Category Permalinks from some posts.
 * This version is just a temporary measure to assure Category Permalink postmeta
   isn’t delete, at least not by the plugin.
 * **It’s recommended to update it ASAP, to avoid this bug from happening and deleting
   your postmeta.** A new version will be released soon with an UI to better handle
   it. Sorry for the inconvenience.

#### 1.00.07

 * First public release.

## 额外信息

 *  版本 **1.00.08**
 *  最后更新：**16 年前**
 *  活跃安装数量 **300+**
 *  WordPress 版本 ** 3.0 或更高版本 **
 *  已测试的最高版本为 **3.0.5**
 *  语言
 * [English (US)](https://wordpress.org/plugins/hikari-category-permalink/)
 * 标签
 * [category](https://cn.wordpress.org/plugins/tags/category/)[custom](https://cn.wordpress.org/plugins/tags/custom/)
   [permalink](https://cn.wordpress.org/plugins/tags/permalink/)[permalinks](https://cn.wordpress.org/plugins/tags/permalinks/)
   [seo](https://cn.wordpress.org/plugins/tags/seo/)
 *  [高级视图](https://cn.wordpress.org/plugins/hikari-category-permalink/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  5 条 5 星评价     ](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/hikari-category-permalink/reviews/)

## 贡献者

 *   [ shidouhikari ](https://profiles.wordpress.org/shidouhikari/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/hikari-category-permalink/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](http://Hikari.ws/wordpress/#donate)