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'm trying to achieve the following permalink structure for a custom post type called "concept" with taxonomy "category"

http://domain/categoryname/conceptname

Note: The main problem here is I don't want the custompost type slug /concept to appear, and now it seems to be conficting with existing rewrite rules

I did

global $wp_rewrite;
$concept_permalink_structure = '/%category%/%concept%/';
$wp_rewrite->add_rewrite_tag('%concept%/','([^/]+)', 'concept=');
$wp_rewrite->add_permastruct('concept/',$concept_permalink_structure,false );

and

add_filter('post_type_link', 'tt_concept_permalink2', 10,3);   

function tt_concept_permalink2($permalink, $post, $leavename ) {

    if($post->post_type != 'concept')
            return $permalink;

    if( !isset($post->ID) ){
        global $post;
    }


    $categories = get_the_terms( $post->ID, 'category');

    if( is_array($categories) && count( $categories ) > 0 ) {
        $cat = $categories[key($categories)]->slug;
        $permalink = str_replace('concept/', $cat .'/', $permalink );
    }

    return $permalink;

}

and it is working!

But!

all other permalink( page, other custom post types ) are giving 404 error!

How can I make them work?

share|improve this question
    
I was in the same situation as you not long ago. I tried coding myself a solution, but found that the WP Permastructure plugin does the best job. Reputable developer as well –  bungeshea Aug 11 '13 at 8:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.