[wp-trac] [WordPress Trac] #14502: Enable /post-type/taxonomy/term/ permalinks
WordPress Trac
wp-trac at lists.automattic.com
Sun Jan 30 13:09:45 UTC 2011
#14502: Enable /post-type/taxonomy/term/ permalinks
-------------------------+-----------------------------
Reporter: scribu | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Permalinks | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+-----------------------------
Comment (by scribu):
Turns out this is almost doable with WP 3.1's post type archives:
{{{
function shape_init() {
register_taxonomy( 'shape-type', 'shape', array(
'rewrite' => array( 'slug' => 'shapes/type' ),
'label' => 'Shape Types'
) );
register_post_type( 'shape', array(
'public' => true,
'has_archive' => 'shapes',
'label' => 'Shapes'
) );
}
add_action('init', 'shape_init');
}}}
The URLs would look like this:
{{{
/shapes/ # all shapes
/shapes/type/3d/ # 3d shapes only
/shapes/triangle/ # a singular shape
}}}
Another variation:
{{{
function shape_init() {
register_post_type( 'shape', array(
'has_archive' => 'shapes',
'rewrite' => array( 'slug' => 'shapes/single' ),
'public' => true,
'label' => 'Shapes'
) );
register_taxonomy( 'shape-type', 'shape', array(
'rewrite' => array( 'slug' => 'shapes' ),
'label' => 'Shape Types'
) );
}
add_action('init', 'shape_init');
}}}
Note: the post type has to be registered before the taxonomy.
Now, the URLs would be:
{{{
/shapes/ # all shapes
/shapes/3d/ # 3d shapes only
/shapes/single/triangle/ # a singular shape
}}}
In both examples, the taxonomy is tied to a single post type.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14502#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list