Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've read a few posts about this, but can't find a clear answer :(

  • I have a custom post type called {ondemand}
  • Within the custom post, I have three taxonomies {speakers} and {categories} and {season}
  • Each taxonomy has 3-4 terms, for example under {speakers} there is one called [joebloggs]

Currently I have a main URL on our site, where the latest post is placed : www.mysite.com/ondemand

When I filter the posts by taxonomy terms the URL defaults to: www.mysite.com/ondemand/{speakers}/[joebloggs] (uses taxonomy.php to display the results)

However I'd like the URL to be like this for any term filtered: www.mysite.com/ondemand/[joebloggs]

Here's the code that I've used in my functions.php - I tried a re-write in each taxonomy (commented out) but that didn't work - they lead to a 404 page.... Any advice or re-code hints would be very much appreciated

/**
* On Demand TV Post Type
*/

add_action('init', 'ondemand');

function ondemand() {

$labels = array(
'name' => __('On Demand TV', 'post type general name'),
'singular_name' => __('TV Episode', 'post type singular name'),
'add_new' => __('New TV Episode', 'TV Episode'),
'add_new_item' => __('Add TV Episode'),
'edit_item' => __('Edit TV Episode Item'),
'new_item' => __('New TV Episode Item'),
'view_item' => __('View TV Episode Item'),
'search_items' => __('Search TV Episode'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => false,    
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => 3,   
'supports' => array('title','editor','comments','thumbnail')
); 

register_post_type( 'ondemand' , $args );

register_taxonomy("Categories", array("ondemand"), 
array("hierarchical" => true, 
"label" => "Category", 
"singular_label" => "Category", 
"rewrite" => true));

register_taxonomy("Speaker", array("ondemand"), 
array("hierarchical" => true, 
"label" => "Speakers", 
"singular_label" => "Speaker", 
"rewrite" => true));
//"rewrite" => array('slug' =>'ondemand', 'hierarchical' => true, 'with_front' => false)));

register_taxonomy("Season", array("ondemand"), 
array("hierarchical" => true, 
"label" => "Seasons", 
"singular_label" => "Season",
"rewrite" => true));
//"rewrite" => array('slug' =>'ondemand', 'hierarchical' => true, 'with_front' => true)));

}
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

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.