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! Link to comment https://forums.phpfreaks.com/topic/232158-wordpress-31-custom-post-type-permalink-problem/ 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! Link to comment https://forums.phpfreaks.com/topic/232158-wordpress-31-custom-post-type-permalink-problem/#findComment-1195469 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? Link to comment https://forums.phpfreaks.com/topic/232158-wordpress-31-custom-post-type-permalink-problem/#findComment-1242342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.