Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I'm working with Wordpress's permalink system, I can create plenty of options for creating permalinks, like so:

/blog/%year%/%monthnum%/%day%/%postname%/

But if I add introduce a new kind of content type, say portfolio pieces, so I can have a url like:

/portfolio/postname/

The permalink options I do have (and have been using for the last 3-4 year's worth of posts), means that end up with ugly urls like:

/blog/portfolio/usual_path

I want all the existing links to work for posts that have already been at:

blog/YYYY/MM/post-name

But I also want to make custom posts available at:

portfolio/post-name

How I'd normally do it

The approach I've normally do would be:

  • remove the hard coded blog slug, from the permalinks to that the new permalink structure was /%year%/%monthnum%/%day%/%postname%/

  • Add a rule in apache to 301 all requests for domain.com/blog/YYYY/MM/DD/old-post to domain.com/YYYY/MM/old-post, for SEO and suchlike.

As far as I know, this would mean that any existing links to

http://domain.com/blog/YYYY/MM/DD/old-post would still work, although browsers would end up at:

http://domain.com/YYYY/MM/DD/old-post

I'd still have the decent urls for custom post types too, at

http://domain.com/portfolio/post-name

Is this how you'd do it?

I feel fairly comfortable about this approach - I could improve the naming structure for SEO while maintaining performance, by removing the days or even years and have something like this:

/%year%/%postname%/

I'm not sure how I'd allow for custom permalink structure here, but is there anything else I should bear in mind here when fixing links like this?

share|improve this question

2 Answers 2

When you register your taxonomy you can create the rewrite rule for the slug

register_taxonomy('investment_country',array('investment'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'country' ), ));

so whenever I'm showing something that I have included in the country taxonomy I get http://www.domain.com/country/unitedkingdom for example

don't forget you'll need to resave your permalinks

share|improve this answer

hope you are created custom pot type called portfolio, as of my understanding just go to custom permalink structure should be /%postname%/

And create custom category or archive template to get hold on porfolio category template

have a look at template hierarchy http://codex.wordpress.org/Template_Hierarchy

in your case your template name should be category-porfolio.php for single.php it should be single-portfolio.php

these templates are exclusive for your portfolio post type

share|improve this answer
    
Hi S kumar, that's not the issue The question is more about routing - because there's a hardcoded 'blog' in the permalinks slug, all custom-post type urls end up with 'blog' prepended. I'm trying to make the content available at a specific url. Thanks anyway though! –  Chris Adams Dec 1 '11 at 11:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.