views:

27

answers:

1

I've got some Wordpress CPTs. They correct URL should be /wordpress/training/training-page/, and that's the URL I see in the admin manage page, but when I click the link the URL I end up with is /wordpress/blog/2010/05/21/training-page/.

I deactivated my plugins with no success. Does anyone know how to keep the correct URL intact?

Here's my code:

<?php
add_action( 'init', 'tv_content_posttype' );
function tv_content_posttype() {
register_taxonomy('content', 
    'training',
    array(
        'hierarchical' => true,
        'label' => 'Content Index',
        'query_var' =>  true, 
        'rewrite' => true
    )
);

register_post_type( 'training',
    array(
        'type' => 'page',
        'labels' => array(
            'name' => __( 'TV Training' ),
            'singular_name' => __( 'TV Training' )
        ),
        'public' => true,
        'rewrite' => array(
            'with_front' => false,
            'slug' => 'training',
        ),
        'hierarchical' => true,
        'query_var' => true,
        'taxonomies' => array( 'content' ),
    )
);
}
A: 

Just a few observations: there's no such thing as a 'type' argument for register_post_type(), so you can get rid of that line. Second, 'with_front' => false is telling WordPress that the URL structure should be /training/training-page/. /wordpress/ in this isntance is the 'front' part you're telling it to leave off. Additionally, you don't need to add 'taxonomies' for the post_type, but you do need to register the post type before you register the taxonomy. So try this:

<?php
add_action( 'init', 'tv_content_posttype' );
function tv_content_posttype() {
register_post_type( 'training',
    array(
        'labels' => array(
            'name' => __( 'TV Training' ),
            'singular_name' => __( 'TV Training' )
        ),
        'public' => true,
        'rewrite' => array(
            'with_front' => true,
            'slug' => 'training',
        ),
        'hierarchical' => true,
        'query_var' => true,
    )
);

register_taxonomy('content', 
    'training',
    array(
        'hierarchical' => true,
        'label' => 'Content Index',
        'query_var' =>  true, 
        'rewrite' => true
    )
);

}
John P Bloch