The Core
Why We Are Here => Web Development => Topic started by: ukgimp 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
-
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.
-
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.
-
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.
-
.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