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 Shteflyuk (http://kpumuk NULL.info)'s sCategory Permalink (http://kpumuk NULL.info/projects/wordpress-plugins/scategory-permalink/) plugin. It has all original features and is compatible with original options, while being more stable and simple, and also fixes 2 recurring bugs.
- Introduction
- Features
- ScreenShots
- Download
- Donate
- Installation
- Upgrading and Uninstalling
- Support & Requests
- Frequently Asked Questions
- Versions
- To-do stuff
- Thanks
- Related Posts
- Comments (4)
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
ScreenShots
- 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
Post permalink by Wordpress default: http://domain.com/ciencia/200/post-name/
Post permalink by Hikari Category Permalink: http://domain.com/consciencia/caos/200/post-name/
License
© Copyright Hikari (http://wordpress.Hikari.ws), 2010
If you want to redistribute this software, please leave a link to this post together with it and mention me as its author
Parts of this code are provided or based on ideas and/or code written by others
Important contributors to this plugin (listed in alphabetical order):
- Hikari Category Permalink is a fork of Dmytro Shteflyuk (http://kpumuk NULL.info)'s sCategory Permalink (http://kpumuk NULL.info/projects/wordpress-plugins/scategory-permalink/) plugin.
- Nikolay Kolev (http://nikolay NULL.com) developed the JavaScript UI software to manage category permalink in posts edit page.
If you want to extend the plugin features, please contact me so I can add your work to my official release.
Download
You can follow Hikari Category Permalink updates and older versions at Wordpress.org Plugin Directory (http://wordpress NULL.org/extend/plugins/hikari-category-permalink/), or you can get the last version from the direct link hikari-category-permalink.zip (http://downloads NULL.wordpress NULL.org/plugin/hikari-category-permalink NULL.zip).
Donate
There are also several ways you can show your appreciation:
- blogging about it
- linking it from your site (without using rel=nofollow )
- browsing the site sidebars
- suggesting it to your friends
- visiting other posts thru the site and adding valuable comments
- saying thanks on comments
- offering codes that add new features
- etc, use your imagination
Installation
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.
- 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/
). - Activate the plugin through the 'Plugins' menu in WordPress admin page.
- 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%/
. - There's no option to be configured. Just try to edit any existing post or create a new one.
- 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 and Uninstalling
I consider very ambiguous the way some plugins should be upgraded and the proper way of uninstalling them, so I believe I should explicitly explain it for my plugins.
I've made an article just to explain in full details which options we have to upgrade and uninstall our plugins and what happens with each option, and how it works with my plugins: Uninstalling my plugins.
For upgrading, simply delete it and follow installation setps again.
Support & Requests
If you want to request any new feature, leave a comment on this post explaining it with as many details as possible. I can't assure it will be added, but if it is viable, I like it AND have the time, I'll do my best.
If something seems to not be working and you need help, first read the FAQ and then leave a comment explaining what's happening. If you need to post a picture, please link it instead of using an img tag.
FAQ
-
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! :DSince 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! :D
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 :)
Cangelog
- 1.00
- First public release.
Known bugs
- none ATM
To-do stuff
Here are my ideas that I wish to implement in the future.
- An options page where we can sort categories in the preference order we wanna use when a post doesn't have its category permalink set. With this feature, we'll have a "default order" other than "use the category with lowest ID" to be used on those posts.
- Make category permalink management UI Unobstructive JavaScript, so that users that can't use JavaScript can also use Hikari Category Permalink.
Thanks
Thanks to dd32 (http://dd32 NULL.id NULL.au/) for accepting my trac ticket (http://core NULL.trac NULL.wordpress NULL.org/ticket/12240) and add into Core the filter I needed to implement this plugin.
Thanks to Dmytro for developing the great sCategory Permalink. It served me for a long time, and it was thanks to the original work that I was able to develop my own plugin.
And of course thanks to all of you that use my plugins, come to my sites and take something useful from it .
I dedicate Hikari Category Permalink to Nikolay Kolev (http://nikolay NULL.com), the author of the JavaScript software used to manage category permalink UI, which was pratically untouched by me and I loved it!
Popularity: 23%
It has accumulated a total of 76,230 views. You can follow any comments to this article through the Comments RSS 2.0 Feed. You can leave a comment, or trackback from your own site.
- feedback
Comentando vc contribui e participa na criação do conteúdo do site.
Contribua. Commente. :)(Os comentários abaixo representam a opinião dos visitantes, o autor do site não se responsabiliza por quaisquer consequências e/ou danos que eles venham a provocar.)
Possible Bug
participate
I've been having a little trouble with the plugin lately. I select a category for the permalink, and I save it, but when I look at it later, it has reverted back to the lowest number category and I have to re-save it. Any idea what might be causing this to happen?
Thanks.
participate
I’ve faced that too, just this week. I noticed my last 20 posts lost their category permalink and I had to reset them again.
I was thinking what might be doing that, but code is very clean and only way of deleting a postmeta would be calling the
savePost()
method.ATM I’m believing the ‘transition_post_status’ action is being called by WordPress in rare situations, maybe when saving drafts, or quick edit or just the posts edit.php page.
Also, there’s no command to delete a postmeta and restore default behavior. Because of all that I’ll just remove the "auto" deleting feature and try to add a command where users can manually delete this meta, and that will be the only way of having a post’s category permalink removed.
Just give me some days and I’ll have it published. We can’t have our data being deleted without our will.
Same problem
information
Hi,
it seems that there is a bug in posts that get puplished in the future. If you set the permalink and set a publish date in the future the permalink gets lost. In our case we are using a structure like "Cat A – SubCat A" If the article gets released than the permalink is only "Cat A" and not Cat A – SubCat B" anymore. Any idea? Thanks, Chris
feedback
Thanks!
Really thanks! With your description I was able to finally find what was wrong with the plugin and fix it!
It was a dumb mistake, inherited by original sCategory Permalink, that I didn't notice. Really sorry about it.
Unfortunatelly, the plugin now requires my new Tools Framework plugin, as almost all other plugins, but I didn't write instructions for installing it yet. And I really really don't have time for it now, I'm totally full of stuff to do and can't take the time to explain to less skilled users how the framework is needed for other plugins to work. And I also need time to do some tests before making it public.
So, it will take some more time for the complete fix to be published. For now, v1.00.08 disables metadata deletion, so I suppose there's no way in this version for having a category permalink being deleted.
I apologize again for the trouble and for not publishing the fix yet.
marketing