sCategory Permalink

Posted by Dmytro Shteflyuk on

Plugin allows to select category which will be used to generate permalink on post edit page. Use custom permalink option %scategory% on Options/Permalinks options page.

Installation

  1. Download and unpack plugin files to the wp-content/plugins/scategory-permalink directory.

  2. Enable sCategory Permalink plugin on your Plugins page in Site Admin.

  3. Open the Options/Permalinks page in Site Admin and use %scategory% option in Custom Structure text field (you can look here for other options). In this blog I’m using /%scategory%/%postname%/ structure.

  4. When you move your mouse over category in Categories box the Primary link will appear on the right.

    Choose a category for permalink generation

    Click it to set the category which will be used to generate permalinks. It will be highlighted with bold.

  5. Have fun!

Upgrade

  1. Download and unpack plugin files to the wp-content/plugins/scategory-permalink directory.

  2. Open the Options/Permalinks page in Site Admin and and click Save Changes to re-generate permalinks.

  3. When you move your mouse over category in Categories box the Primary link will appear on the right. Click it to set the category which will be used to generate permalinks. It will be highlighted with bold.

Demonstration

I have recorded a small screencast on how sCategory Permalinks works starting from version 0.6.0:

Requirements

Plugin works pretty well with the WordPress 2.7.0 — 2.8.2. Hey users of WordPress 2.7.0, could you explain why do you use so old buggy crap? Use new one instead, at least it looks more beautiful!

Download

Latest version of sCategory Permalink is 0.6.2, and it could be downloaded here:

version0.6.2DownloadsCategory Permalink

Also you can download older versions from plugin home page on WordPress.org (but do you really need this old stuff?).

Frequently Asked Questions

Q. Every page on my site responds with error 404
A. Go to Options/Permalinks page in Site Admin and click Save Changes to re-generate permalinks.

Q. First category is used for permalinks instead of selected
A. Check the permalinks structure you used (Options/Permalinks). You should use %scategory% instead of %category%.

Q. I love this plugin. How to do a favor to the author?
A. Just vote for this plugin on WordPress.org. And thank you!

Support

If you have any suggestions, found a bug, or just wanted to say “thank you”,– feel free to contact me. Promise, I will answer to every message.

If you want to contribute your code, see the Development section below.

Development

Sources of this plugin are available both in SVN and Git:

Feel free to check them out, make your changes and send me patches. Promise, I will apply every patch (of course, if they add a value to the product). Email for patches, suggestions, or bug reports: [email protected]. Also you have much more ways to contact me.

Changelog

  • 0.6.2 (July 30, 2009)
    • Nothing really changed. Just to force WordPress to update version.
  • 0.6.1 (July 30, 2009)
    • Fixed blank page when post edit page requested.
    • Fixed “Primary” link appear on all sub-categories, when category selected.
  • 0.6.0 (July 30, 2009)
    • Client side script completely rewritten. New visual look and better usability (thanks to Nikolay Kolev).
  • 0.5.0 (July 28, 2009)
    • Fixed problem with Subscribe2 plugin (thanks to Paul Wagorn).
    • Performance improvement (update meta tags only once per save).
  • 0.4.0 (July 21, 2009)
    • Fixed not-found bug when /%year%/%scategory%/%posttitle% permalink used.
    • Fixed not-found bug when paged comments enabled (/comment-page-N).
    • JavaScript rewritten using jQuery library.
  • 0.3.0 (April 4, 2008)
    • Fixed bug when pages was not found in WordPress 2.5.
  • 0.2.2 (May 20, 2007)
    • Sometimes radio buttons was not displayed (thanks to Vince Caughley and Sam Keen).
  • 0.2.1 (Apr 1, 2007)
    • Removed dependency on deprecated WordPress 1.5 function wp_get_post_cats.
  • 0.2.0 (Mar 30, 2007)
  • 0.1.0 (Nov 18, 2006)
    • Initial plugin implementation.

Other plugins

Full list of plugins I have implemented is available here.

125 Responses to this entry

Subscribe to comments with RSS or TrackBack to 'sCategory Permalink'.

said on May 7th, 2009 at 21:31 · Permalink · Reply

What version of WordPress and scategory_permalink do you use? In this blog I’m using latest stable WordPress and plugin, and see no problems with pages.

paul
said on May 7th, 2009 at 21:36 · Permalink · Reply

HI,

I’m using WP 2.7.1

permalink is /%year%/%scategory%/%postname%/

I’m wondering if it could possibly be a plugin conflict? I’m using:

All in One SEO Pack 1.4.91
Another WordPress Classifieds Plugin 1.0.4.8
Audio player 2.0b6
Better Blogroll 2.9
Exclude Pages from Navigation 1.51
Exec-PHP 4.9
Google XML Sitemaps 3.1.2
Nofollow Links 1.0.3
Subscribe2 4.15
WP-EMail 2.40
WP-PostViews 1.40

thanks

said on May 7th, 2009 at 21:58 · Permalink · Reply

Ok, I have dirty solution for you. Find the following link in scategory_permalink.php:

1
if (0 === strpos($structure, '%scategory%'))

and replace it with:

1
if (strpos($structure, '%scategory%') >= 0)
paul
said on May 7th, 2009 at 22:06 · Permalink · Reply

Works perfectly. Thank you so much.

I have never had anyone respond so quickly to problems as you have – even to the point of doing some custom programming for me.

Inspires myself to do better. thank you.

said on May 7th, 2009 at 22:08 · Permalink · Reply

Thank you for your report. This change will be integrated into the upcoming release, so update would not break anything.

said on May 8th, 2009 at 02:40 · Permalink · Reply

I had same problem paul had when I installed scategory, I’m sad I didn’t have the same support that time :P

I wanted to use /%post_id%/%scategory%/%postname%/ as permalink, but it was breaking pages. Only solution I found was to use /%scategory%/%post_id%/%postname%/ instead.

I will give it a try with your fix, but now I started to feel that having post ID separating category to postname is the best structure after all :P

But I’d like to make a request. When we have a category nested inside another, both of them are used on permalink. I’d like to have only the nested one showing on some cases, but still both of them on other cases… Do you think this can be implemented? :p

Using my site http://Hikari.ws as example.

I have a lot of posts using the category http://hikari.ws/cats/entretenimento/vogonismo/, one of them is http://hikari.ws/entretenimento/vogonismo/291/o-pq-de-eu-naum-gostar-dos-vegetarianos/.

I’d like it to be http://hikari.ws/vogonismo/291/o-pq-de-eu-naum-gostar-dos-vegetarianos/. This URL works, but WordPress keeps generating the /entretenimento/vogonismo/ URL, and thanks to Permalink Redirect it goes back to /entretenimento/vogonismo/ as soon as /vogonismo/ URL is used.

But on the other hand, posts based on http://hikari.ws/cats/tutorial/en/ category must keep the /tutorial/en/ permalink, to indicate their language.

Since your plugin is able to tweak WP permalink core, I belive this can also be done, but I’m not good enough on PHP to implement it. In User Interface, it would be a matter of choosing to use whole category path or only the nested one.

I can beta test it with you if you want, I have 2 blogs (1 of them using scategory for a few months, the other will have it implemented next week!) and I can install as many development blogs as I want to make tests.

said on May 8th, 2009 at 02:43 · Permalink · Reply

Another question, which plugin do you use for code formatting on comments?

I use WP-Syntax and it doesn’t work on comments…

said on May 12th, 2009 at 19:06 · Permalink · Reply

Is there a way to use the scategory to display in a template? I’d love to designate a “primary” category which I display in my template. Maybe you could add a function in future versions that allows this? Or is there one already that I missed?

Thanks, and great plugin!
RB

said on May 18th, 2009 at 20:53 · Permalink · Reply

Hi,

I am using the following permalink structure

/%category%/%year%-%monthnum%-%day%-%postname%/

This plugin is not working for this permalink structure & I am using WordPress 2.7.1

Please suggest me the fix.

Thanks.

said on May 19th, 2009 at 13:09 · Permalink · Reply

Freshers Jobs– If you’ll read the top of THIS PAGE… you’ll see it says you need to use %scategory%.

Please do a double check before posting in the future.

said on May 19th, 2009 at 18:22 · Permalink · Reply

I just found out the permalink is stored in the meta field: _category_permalink which is relatively simplistic to draw out. Hooray!

said on May 22nd, 2009 at 08:54 · Permalink · Reply

looks like the plugin is breaking the pagination of the blog ( ie domain.com/page/2/ doesn’t work anymore). ie “more entries” link at the bottom

is there a fix for this?
thanks!

said on June 8th, 2009 at 21:04 · Permalink · Reply

Weird, having trouble getting radio button box to appear. I’m using: /%category%/%postname%, changed the %category to %scategory, saved that.

I now get, in my post pages, the permalink name being:
http://dgeneratefilms.com//postname, and the only option being to edit the postname. Plugin is installed. On WP 2.7.1.

Paul
said on June 9th, 2009 at 20:57 · Permalink · Reply

ARRGH!

Every time I publish a story, no matter what category I choose, the url permalink changes to uncategorized as soon as I publish it.

This is obviously a major problem even if I change it after the fact, as all my email notifications go out with the uncategorized category.

I have a feeling that this happens when the category that was first chosen for the permalink is changed (& saved of course) before it’s published. the plugin gets confused & it reverts back to uncategorized.

now my htaccess is full of 301 redirects that I have to set up because I have to change the permalink back to what it’s supposed to be right after it’s published.

is there a fix for this bug? it’s really causing some major problems.

thanks!

Paul
said on June 12th, 2009 at 07:49 · Permalink · Reply

hi, my comment is still under moderation….

I’m having major problems with the plugin making everything in the uncategorized category as soon as i publish it…!

thanks

said on June 15th, 2009 at 08:38 · Permalink · Reply

I can’t post articles to my blog until this is sorted out….

and I cannot disable the plugin, as all my categories will get messed up.

help !!!

said on June 20th, 2009 at 05:23 · Permalink · Reply

Dmytro – Great plugin!

@Randall or Dmytro – I’m also trying to find a way to access the scategory variable in a theme/template. Is there a straight-forward PHP call to output it?

said on June 20th, 2009 at 05:34 · Permalink · Reply

Alright, am going to be that guy that answers his own question. Sorry, should have just investigated it further before posting.

Here’s how to pull the selected category (scategory) ID and print it in a theme/template file:

This will get the information in an array:

1
$scategory = get_post_custom_values("_category_permalink");

And this will print it:

1
print $scategory[0];

Thanks again for this awesome plugin Dmytro!

said on July 4th, 2009 at 12:34 · Permalink · Reply

It simply does’t change the category – everything is on place, the ratio etc., but if I want to choose a category for my permalink, I just can’t! I click save and than edit and than save again………….. nothing!
I’ve got this post: http://mysite.co.uk/somecategory1/post-bla-bla/, published in 2 different categories: somecategory1 and somecategory2. It is actually not possible to change the automatically chosen category1. I don’t know why WP prefers the category1 :(((

Randall
said on July 13th, 2009 at 16:06 · Permalink · Reply

@ryan or anyone else with the custom field question… since its a custom field there are a bunch of ways to get at it. I use a plugin called “flutter” which adds tons of other CMS-like functions to get at custom data. You could also use c2c_custom_get() which I think is pretty rad too.

said on July 14th, 2009 at 08:07 · Permalink · Reply

I don’t use subcategories at all. The plugin works, except the emails that get sent out are under uncategorized.

also, it USED to work perfectly until the update. I wouldn’t have used it if it didn’t work. Now it doesn’t function and it’s impossible to remove the plugin without wrecking my blog urls.

I’m not using /%category%/%postname%/

I’m using /%category%/%year%/%postname%/

said on July 18th, 2009 at 04:36 · Permalink · Reply

Is there a fix for this plugin and the “uncategorized” problem yet?
My 2000+ subscribers are getting the wrong URLs still.

thanks

Randall
said on July 18th, 2009 at 15:09 · Permalink · Reply

Paul,

If you’ll read at the top of this page, it’s actually your fault why it’s not working properly.

“Go to the Options/Permalinks page in Site Admin and use %scategory% option in Custom text field (you can look here for other options). In this blog I’m using /%scategory%/%postname%/.”

It should be /%scategory%/ not /%category%/ like you listed in a previous comment.

said on July 18th, 2009 at 15:32 · Permalink · Reply

No, that was a typo in response to the fact that you told me I was using:
/%category%/%postname%/

I’m actually using:
/%year%/%scategory%/%postname%/

Randall
said on July 24th, 2009 at 01:17 · Permalink · Reply

Problem… I think thanks to the new comments structure, scategory permalink breaks my site and I get 404 errors when someone posts a comment.

said on July 24th, 2009 at 02:05 · Permalink · Reply

Could you post a link to your site so I will be able to track where is the problem? I want to know the permalink structure and check if paged comments are enabled. The problem should not be so hard to fix.

Thank you!

said on July 24th, 2009 at 02:32 · Permalink · Reply

I see you’re using scategory_permalink version 0.3.0, but this error has been fixed in 0.4.0 days ago. Could you upgrade it and click “save” on Permalinks options page to re-generate permalinks structure?

Thanks!

Randall
said on July 24th, 2009 at 02:36 · Permalink · Reply

D’oh. Thanks!

Silly lack of checking upgrades.

said on July 28th, 2009 at 16:44 · Permalink · Reply

I will gladly pay for someone to fix the problem with this plugin. my blog has 2000 subscribers who do not get the right url in their notifications anymore, and it is a major problem.

I cannot seem to get a response from the author, other than a kurt “it’s your fault”, with incorrect assumptions.

Anyone out there who can help?

Toly
said on July 30th, 2009 at 04:08 · Permalink · Reply

I just upgraded to 0.6.0 and it seems there is a conflict with WP 2.8.2. When I go to add/edit post, I get a blank page.

I’m using the WP MU version but I haven’t had any issues with previous versions of this plugin.

Toly
said on July 30th, 2009 at 16:53 · Permalink · Reply

Thanks for the fix.

Ruzanna
said on August 6th, 2009 at 13:36 · Permalink · Reply

i’m using wordpress 2.7.1. and scategory 0.6.2. everything was working perfectly with scategory 0.3.0., but once i updated to 0.6.2., the plugin stopped working, there is no ‘primary’ button appearing when i move the mouse over the category names. please advise.

Ruzanna
said on August 6th, 2009 at 13:50 · Permalink · Reply

and here is the list of all plugins i use:

Add Meta Tags 1.6
Add to Any: Share/Bookmark/Email Button .9.9.3.4
Akismet 2.2.6
Bad Behavior 2.0.28
Dagon Design Form Mailer 5.6
Digital Fingerprint Beta 0.2
External Links 3.0.4
Google XML Sitemaps 3.1.4
Role Manager 2.2.2
sCategory Permalink 0.3.0
SEO Friendly Images 2.4.2
SEO Slugs 1.0
Thumbnail For Excerpts 1.3
WordPress Database Backup 2.2.2
Yet Another Related Posts Plugin 3.0.8

said on August 24th, 2009 at 16:57 · Permalink · Reply

Just a heads up… the “Primary” link doesn’t appear in Chromium for Mac… which is admittedly a beta, but yeah. Would love an option to re-enable radio buttons, but understand if that’s not exactly a high priority.

Angie
said on September 3rd, 2009 at 14:20 · Permalink · Reply

Hi Dmytro!
GREAT GREAT GREAT plugin!

but it doesn’t work in my blog :(
I use WP 2.7.1 and the last version of your plugin
I activated it and I changed the permalink with %scategory% then save but…nothing happens! I can’t see the radio button, the “primary” link, I don’t even have the 404 error when I access to my posts that still have the old permalinks!
How can I fix it?

Thank you so much, and sorry for my bad english

said on September 5th, 2009 at 11:10 · Permalink · Reply

Same problem here with WP 2.7
I can’t see any ajay primary link appearing in the category widget. Also when I change category, it puts all the postings to my primary default category
Any idea how to fix?
Thanks

said on September 16th, 2009 at 16:21 · Permalink · Reply

This plugin is not working for me for quite some time (sorry, but I didn’t kept track of both the plugin and WordPress version).

On the editor window I can see the “Primary” link and (still in the editor window) it seems to work, but if I use:

1
/%scategory%/%postname%/

and then navigate my site, I get the 404 error on every post. Of course I tried to regenerate the permalinks.

Any idea.

said on September 23rd, 2009 at 15:46 · Permalink · Reply

This is a true gem of a plugin, just wanted to let you know that.

And also I noticed (on WP 2.9-rare) that the plugin doesn’t work for previewing posts, the category doesn’t use the scategory.

I love this plugin.

said on September 23rd, 2009 at 16:02 · Permalink · Reply

MANY MANY people are getting the below error

1
2
3
"Fatal error: Call to undefined function add_action()"
....
"plugins/scategory-permalink/scategory_permalink.php on line 33"

Same with me. How to solve this ?

regards,
ASHISH THAKKAR

said on September 23rd, 2009 at 16:55 · Permalink · Reply

It means that your version of wordpress is old and exploitable. you need to upgrade.

said on October 15th, 2009 at 22:41 · Permalink · Reply

After installing all my posts show 404. I regenerated the permalink structure several times. I want my permalinks to look like this:

1
/%scategory%/%postname%-event.htm

I’ve read all the above comments and I saw that there might be a problem with having “.htm” at the end of my permalink structure.

I also have the WP No Category Base plugin installed.

said on October 16th, 2009 at 12:09 · Permalink · Reply

Thank you for your bug report. I will check it and fix soon (there is one more bug has been fixed yesterday with WordPress 2.7, so the new version will go to public in nearest future).

More comments: 1 2 3

Post a comment

You can use simple HTML-formatting tags (like <a>, <strong>, <em>, <ul>, <blockquote>, and other). To format your code sample use [cc lang="php"]$a = "hello";[/cc] (allowed languages are ruby, php, yaml, html, csharp, javascript). Also you can use [cc][/cc] block and its syntax would not be highlighted.

Submit Comment