1

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?

2 Answers 2

1

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

0

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

1
  • 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! Dec 1, 2011 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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