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.

I've searched around but have not been able to find an answer to my question.

What I'm trying to do is create a custom post type that exists within a sub-directory, not just after the root as is default.

For example right now I have:

http://www.mysite.com/custom-post-type

I would like to have:

http://www.mysite.com/subdirectory/custom-post-type

The reason I'm trying to do this is that I have a client that now has additional clients that I would like to have named as a sub-directory, and not an entirely new sub domain.

I was planning on creating custom post types to create the additional blogs or the two other clients, but I can't find a way of having a sub-directory first.

Is there an easy way to do this? I'm decently versed in WP but not an expert, so I'm hoping there is an easy-ish method.

Thanks for any guidance

share|improve this question

1 Answer 1

up vote 1 down vote accepted

When you register your post type, add the subdirectory to the has_archive argument, and as the slug argument of the rewrite argument:

$args = array(
    // ... other args removed for clarity
    'rewrite' => array( 'slug' => 'subdirectory/custom-post-type' ),
    'has_archive' => 'subdirectory/custom-post-type',
    // ...
);
register_post_type( 'your_cpt', $args );
share|improve this answer
    
Awesome, worked perfectly. Thanks a ton. –  Ben Jun 18 '13 at 15:56
    
Is it also possible to do the same thing with taxonomies? I tried putting the same path into the rewrite slug but I'm having trouble with it picking up my taxonomy-taxonomyname.php file. Any idea how to accomplish this? Thanks. –  Ben Jun 18 '13 at 17:32
    
It should work for taxonomies as well. add the code you are using to the question, or perhaps it's best to ask a new question and provide the details there. –  Milo Jun 20 '13 at 2:51

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.