Author Topic: Multiple Permalink Structures for Different Categories  (Read 2499 times)

ukgimp

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2241
    • View Profile
Multiple Permalink Structures for Different Categories
« on: November 06, 2012, 03:52:22 PM »
Looking for an efficient solution for a wordpress scenario. I would like to avoid plugins

eg posts

Category 1
/news/11-06-2102/

Category 2
/reviews/the-post-title.htm

Anyone done this?

Hoping to avoid multiple installs of WP

Cheers


IrishWonder

  • Inner Core
  • Hero Member
  • *
  • Posts: 561
    • View Profile
    • IrishWonder's SEO Consulting
Re: Multiple Permalink Structures for Different Categories
« Reply #1 on: November 07, 2012, 09:02:15 AM »
If you can code and can be arsed (which I assume is the case if you want to avoid plugins) I believe you can write a nice function that does that depending on the category. If not then I think there actually are plugins for this.

grnidone

  • Inner Core
  • Hero Member
  • *
  • Posts: 1649
    • Yahoo Instant Messenger - e
    • View Profile
    • Email
Re: Multiple Permalink Structures for Different Categories
« Reply #2 on: November 07, 2012, 03:48:27 PM »
Can't you just manually tweak the .htaccess file and make this happen?  I mean, the categories aren't going to change frequently, are they?  Actually, I think wordpress does this for you.

Am I not understanding what you're doing?  This doesn't sound that difficult.  PM me and let me take a look.

ergophobe

  • Inner Core
  • Hero Member
  • *
  • Posts: 9293
    • View Profile
Re: Multiple Permalink Structures for Different Categories
« Reply #3 on: November 07, 2012, 05:26:17 PM »
I think you could do something at the theme level using the Rewrite API. Since it's an API, it's not likely to break as readily as a plugin with a full interface and everything. Should be a an easy little script addition.

http://codex.wordpress.org/Function_Reference/WP_Rewrite


Can't you just manually tweak the .htaccess file and make this happen?  

.htaccess doesn't create URLs, it just acts as a traffic cop for incoming URLs. The problem is that WP gives very little flexibility over URL patterns.

You can do %category%/%postname% but you can't do any if/then logic. What gimpie needs is

if %category% == 'news'
    pattern = /%category%/%monthnum%-%day%-%year%/

elseif %category == 'reviews'
    pattern = %category%/%postname%.htm

I gotta ask, why .htm? Do you have legacy URLs to deal with?

I would go with
 - extensionless URLs
 - yyyy-mm-dd dates or, distant second choice, dd-mm-yyyy. The former simplifies sorting if you ever need to output and sort URLs by date.
« Last Edit: November 07, 2012, 05:30:18 PM by ergophobe »

ukgimp

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2241
    • View Profile
Re: Multiple Permalink Structures for Different Categories
« Reply #4 on: November 07, 2012, 11:10:44 PM »
.htm

Just an example.

I tend to use folders for many things as it removes the platform dependancy, but I am unlikely to move off lamp so not really a problem.

As said htaccess is just one part, you need the URL to be written into the template via HTML

One reason is for inclusion in google news whee named and dates are not enough. You have to have some unique number.

I will feed back if I work it out