jenkyjay Posted March 30, 2011 Share Posted March 30, 2011 Hi, I have 3 custom post types setup and I have created a custom permalink structure for each. The problem I am having is that the third custom post type I have setup with the custom permalink, is being used for the previous 2. Example: Classified Employment Sponsorship The above are the post types and I have the custom permalink structure set to (for each): /post_type/post_id/ Now, The above order are the order they are set in and sponsorship takes over all of them. So for instance: /classified/100/ /employment/101/ /sponsorship/102/ The above all use the permalink: /sponsorship/100/ /sponsorship/101/ /sponsorship/102/ What am I doing wrong to get this error happening? Is it a permalink structure error? below is my code I am using to create the custom permalink structures for each. The only difference is that %c_id% is changed to %e_id% and %s_id% for classifieds, employment and sponsorship. And also any reference to 'classifieds' is changed to employment and sponsorship respectively. add_action('init', 'classifieds_rewrite'); function classifieds_rewrite() { global $wp_rewrite; $queryarg = 'post_type=classifieds&p='; $wp_rewrite->add_rewrite_tag('%c_id%', '([^/]+)', $queryarg); $wp_rewrite->add_permastruct('classifieds', '/classifieds/%c_id%/', false); } add_filter('post_type_link', 'classifieds_permalink', 1, 3); function classifieds_permalink($post_link, $id = 0) { global $wp_rewrite; $post = &get_post($id); if ( is_wp_error( $post ) ) return $post; $newlink = $wp_rewrite->get_extra_permastruct('classifieds'); $newlink = str_replace("%c_id%", $post->ID, $newlink); $newlink = home_url(user_trailingslashit($newlink)); return $newlink; } Thanks for the help! Quote Link to comment Share on other sites More sharing options...
jenkyjay Posted April 1, 2011 Author Share Posted April 1, 2011 Any suggestions? I'm willing to try anything! Quote Link to comment Share on other sites More sharing options...
digitaloutback Posted July 13, 2011 Share Posted July 13, 2011 Hi did you find out a solution? I think the problem is down to this line: $newlink = $wp_rewrite->get_extra_permastruct('classifieds'); I too am stuck on this now, it looks like it wasn't developed to alter permalink changes to more than one post type? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.