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.

The Dilemma

I have a few custom post types:

  • Portfolio Items
  • Testimonials
  • FAQs

The URL structures for these custom post types are:

  • mysite.com/portfolio/name-of-custom-post
  • mysite.com/testimonial/name-of-custom-post
  • mysite.com/faq/name-of-custom-post

I'd like to use the normal, built-in WordPress post type to control our blog entries, and have the URL for each blog entry be like this:

  • mysite.com/blog/name-of-post

If I go to Settings > Permalinks and adjust the URL structure to be like...

/blog/%postname%/

...then the URLs for all of my post types are affected, which results in:

  • mysite.com/blog/portfolio/name-of-custom-post
  • mysite.com/blog/testimonial/name-of-custom-post
  • etc...

The Question

What I'd like to know -- is it possible to adjust the URL structure for the built-in WordPress post type without affecting the URL structure of other custom post types?

The only other way I see to solve my dilemma is to create another custom post type called "Blog." This seems wasteful, because then I won't be using the built-in WordPress post type at all.

If anyone needs it, The Why

If anyone wonders why I need "blog" in the URL so badly, it's because we're merging our blog into the same install as our site, and want to keep the URLs intact so we don't lose valuable Google juice.

Any help is greatly appreciated -- thanks!

share|improve this question
    
I just asked this same question almost word for word, glad I found this, thanks –  jasondavis Oct 18 '12 at 20:07
add comment

2 Answers 2

up vote 6 down vote accepted

You could do this on custom post type registration.

1) Set your default permalink in the WordPress admin to your desired structure e.g.:

/blog/%postname%

2) Add the "slug" and "with_front" parameter to the rewrite-array in the register_post_type function. "slug" must be the name of your post-type.

  $args = array(
    // ...
    'rewrite' => array(
        'slug' => 'your_post_type',
        'with_front' => false
    ),
    // ...
  ); 
  register_post_type('your_post_type',$args);

This should generate the following rewrite-rules:

Default Post: http://example.com/blog/%postname%
Default Page: http://example.com/%postname%
Custom Post Type: http://example.com/your_post_type/%postname%

EDIT

The "slug" parameter is optional. If you don't set it, the name of your custom post type is used. Check out the function reference about register_post_type: http://codex.wordpress.org/Function_Reference/register_post_type

share|improve this answer
    
You are absolutely the man. This works perfectly; thank you! –  Ryan Mar 31 '11 at 16:12
    
@rofflox. Please take a look at this ( wordpress.stackexchange.com/questions/52471/…) question. I tried your answer but that did not help me. –  Average Joe May 17 '12 at 20:09
add comment

Alternative - You can setup permanent 301 redirects. This will send people on to the correct link and keep your google juice intact. I don't know the answer to your specific question though.

share|improve this answer
    
Thanks mrtsherman. I asked our SEO person about doing that, and am told that you lose a little bit of Google juice by doing 301 redirects. I'd love to not lose any, but if all else fails I may just go this route. –  Ryan Mar 30 '11 at 5:17
    
@Ryan - +1 funny my company just asked to do the exact same thing as this yesterda afternoon. Hopefully someone comes through. –  mrtsherman Mar 30 '11 at 14:01
add comment

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.