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. It has all original features and is compatible with original options, while being more stable and simple, and also fixes 2 recurring bugs.
- You can choose for each post separately, which category is used in its
- 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
- 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
- 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 🙂
Just downloaded, seems to work on 4.3
- 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.
- First public release.