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 have been researching this for over a week now. I've tried a few tutorials on custom rewrite rules and custom post types, but I'm still not sure which direction I should go in for making this happen. And it absolutely has to happen. This is a large client who needs to retain the same link structure that is coming from a moveable type envrionment:

WP ---> http://www.domain.com/pastissues/category/here-is-the-postname.html - works on wordpress

MT ---> http://www.domain.com/pastissues/multiple-word-category-orsingle-one-here-is-the-postname.html - works on Moveable Type

I've tried:

/pastissues/%category%-%postname%.html --> this produces the right looking link, but fails when I request an article if the article has a category that is more than one word.

So I probably need to write a custom permalink plugin. I've tried looking through available plugins out there, but custom permalinks won't help me, because I'm a multi-site install.

share|improve this question
add comment

3 Answers

Or, you can do that - after headhache and spent one day to find a solution :

You have to set 'rewrite' => false in your register_post_type(); and add after closing register_post_type() :

// 404 CPT permalink WP bug...
global $wp_rewrite;
$projet_structure = '/projets/%projet%';
$wp_rewrite->add_rewrite_tag("%projet%", '([^/]+)', "projet=");
$wp_rewrite->add_permastruct('projet', $projet_structure, false);

Where projet is my CPT

See here for more.

Enjoy !

share|improve this answer
    
Good to know....thanks. I will try everything everyone is suggestion until the right combination of code and parameters finally works. And I promise to actually follow up with the solution, should I find it, in this thread. –  yoyodyne Feb 7 '13 at 21:20
add comment

I had to deal with custom post types and custom permalinks recently. Some examples of how to do this (including with categories) are here:
http://xplus3.net/2010/05/20/wp3-custom-post-type-permalinks/
and
custom slug for custom post type

It seems that after implementing this you will get 404s unless you go to settings-->permalinks and press save; this rebuilds the URL parser ruleset or something like that.

If you still get 404s you may be having the same problem I did. In which case you'll need to add add_rewrite_tag as Milo guided me to here:
custom post type 404s with rewriting even after resetting permalinks

share|improve this answer
    
Ok, thanks. Reading up on it now. One thing I don't see mentioned anywhere is how to import thousands of posts from something like Moveable type and desginate them as the new post type you've created. –  yoyodyne Feb 1 '13 at 19:17
add comment
up vote 0 down vote accepted

So in the end, here is what I've concluded. Doing the above is doable if you write or use a migration script that transposes the MT3 or 4 data into WP mappings...such as Title, Primary Category, etc. So assuming that all works fine, you then concatenate the category name separated by hyphens onto the title making it the postname going into Wordpress (doing this in your migration script somehow). Then you assign everything a permastructure of: /pastissues/%postname%.html. from the Settings->Permalinks GUI.

That will work for the migrated posts. Still, the client wants an ongoing permastructure of %day%/%month%/%year%/%postname%/ for anything post-migration. This is completely understandable.

So my solution is to import the posts with their associated category name concatenated onto the title to make the postname (I really only think this will work for single category to article assignments...rather than multiple category to articles coming from moveable type) and then make ALL of those posts a custom post type of some sort.

Next, either assign them a permalink structure in the custom post type plugin one writes or use wp_permalinks plugin to assign the permalink to the pastissue post type. And then use the permalink gui to assign the %day%/%month5/%year%/%postname%/ structure to new posts going forward.

share|improve this answer
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.