sCategory Permalink

Posted by Dmytro Shteflyuk on · Русский (205,459 views)

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: kpumuk@kpumuk.info. 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.

113 Responses to this entry

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

said on December 15, 2008 at 3:09 am · Permalink · Reply

в 2.7 всё сломалось(

said on December 15, 2008 at 3:01 pm · Permalink · Reply

Достаточно просто пересохранить пермалинки на странице администрирования – и все работает.

said on December 16, 2008 at 2:20 am · Permalink · Reply

Как я рад, что всё ещё живо)
только я не могу найти где это можно сделать.

Jon
said on January 3, 2009 at 5:22 pm · Permalink · Reply

This is a great plugin, but is there a way to do it without using %scategory% and just the standard %category%? I’d like the actual permalink to be manipulated upon saving the post.

I’m building a site where posts are categorized under several different sub-categories, but I want the permalinks to be created from only one set. But I would like the posts to appear in the pages for the other categories as well.

I’d like for permalinks to be /issues/july-2009/post-name.html and I would like to be able to go to /topics/development and see the post listed there. With %scategory% I currently get a 404 for /topics/development. How can I manipulate the actual permalink creation not using %scateogry%?

Let me know if you need more clarification and thanks for all the great work you have out into this plugin!

said on January 4, 2009 at 4:00 pm · Permalink · Reply

Hey Jon,

Thank you for your great proposal. I definitely have to implement this feature in nearest release (I’m working on it now). Stay tuned!

Евгений @
said on January 25, 2009 at 7:58 pm · Permalink · Reply

Спасибо дмитрий за отличный плагин, но вот в 2.7 перестали нормально коментарии работать. При постинге пишет что страница не найдена.

said on January 26, 2009 at 2:15 am · Permalink · Reply

Да, Евгений, спасибо. Тоже заметил, ищу решение, недеюсь, скоро получится исправить. Эта ошибка проявляется, если включить разбивку комментариев на страницы, потому если Вам не критично, можете отключить эту возможность дабы избавиться от ошибки. А там я и плагин поправлю :-)

Евгений @
said on January 26, 2009 at 7:34 am · Permalink · Reply

Я просто файл wp-comments-post на старый поменял, там редирект иначе сделан. Спасибо.

Hikari @
said on February 6, 2009 at 11:37 pm · Permalink · Reply

Great plugin, I really loved it!!

And it works fine with WP 2.7!

Hikari @
said on February 9, 2009 at 9:49 am · Permalink · Reply

Well, after some tests I found out the 404 bug too…

My permalink was the tradicional /%year%/%monthnum%/%day%/%postname%/ and I changed it to /%post_id%/%scategory%/%postname%/

During the past week I’ve been testing a lot of configs, tried to mix scategory with permalink-redirect and top-level-cats, it made a too much trastic change in WP core and something was always not working.

After learning more about htaccess and trying to redirect error permalinks to working ones, I abdicated of top-level-cats and made most of permalink-redirect directly in htaccess, leaving only scategory.

But something is still not working. As soon as I change parmalink, pages URLs break. They all start returning 404 and nothing can stop it.

Hikari @
said on February 9, 2009 at 9:51 am · Permalink · Reply

The 2 things that I can’t let go is the new permalink structure and the ability to choose which category will be used for each post.

But I also can’t break date archives and much less pages, so I’m in a dead end now.

If I find a solution I’ll come back share it, but any help is also very apreciated :(

said on March 7, 2009 at 1:12 pm · Permalink · Reply

Увы, получаю ошибку 404. WordPress 2.6.1

Serenine @
said on March 12, 2009 at 6:35 pm · Permalink · Reply

Hello Dmytro,

Thank you for providing a great plugin.
I am having the same problem as Jon with subcategories. At this point I am getting a 404 when someone submits a comment. No 404 elsewere. I hope to hear about solution soon. Thank you.

Permalink: /%scategory%/%postname%/ before /%category%/%postname%/
WP 2.7.1 + sCategory 0.3.0

Serenine @
said on March 12, 2009 at 8:34 pm · Permalink · Reply

Hi,
After searching. I disabled comments paging in Settings > Discussion and it seems to be working.

I don’t think I have the same issue as Jon like I initially posted.

Thanks for a great plugin. Will be sure to make a donation soon.

said on April 4, 2009 at 10:14 am · Permalink · Reply

I second Jon’s request above but for a slightly different reason. My permalink structure uses .html and sCategory Permalink strips this resulting in problems with other plug ins.

paul @
said on May 7, 2009 at 9:07 pm · Permalink · Reply

Help!!!

I installed this plugin, it seemed to work correctly, but now all my Pgaes (pages, not posts) all result in 404′s.

how do I finx this? even after disabling the plugin, is still doesn’t work !!

paul @
said on May 7, 2009 at 9:19 pm · Permalink · Reply

actually, sorry, the problem goes away when I completely deactivate the plugin… but of course none of the inbound links to my blog link to the right pages because all the urls changed back to default categories.

help, is there a fix for this?

said on May 7, 2009 at 9:22 pm · Permalink · Reply

paul, just go to Options/Permalinks and check the permalink structure (should be %scategory%). Then click save to regenerate permalinks.

paul @
said on May 7, 2009 at 9:29 pm · Permalink · Reply

Yes, that’s what I did when I installed it, and it worked fine, however the Pages (again, pages, no posts) stopped working – they all resulted in 404′s.

the temporary fix for me was to go back to the %category% method… this actually didn’t work (even after re-saving), and I had to actually deactivate the plugin for it to start working.

NOW, the big problem is that my permalinks have reverted back to the originales (ie with categories other than the ones I selected with your pluin), and so links coming into my site all point at pages that do not exist.

The main problem is that your plugin causes my pages to 404. The secondary problem is that my inbound links are messed up now because i had to deactivate the plugin to make my site work.

said on May 7, 2009 at 9:31 pm · 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 7, 2009 at 9:36 pm · 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 7, 2009 at 9:58 pm · 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 7, 2009 at 10:06 pm · 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 7, 2009 at 10:08 pm · Permalink · Reply

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

Hikari @
said on May 8, 2009 at 2:40 am · 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.

Hikari @
said on May 8, 2009 at 2:43 am · 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 12, 2009 at 7:06 pm · 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 18, 2009 at 8:53 pm · 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.

More comments: 1 2 3 4

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