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 have Volume and Issue as separate Taxonomies and all Posts have a Volume and Issue assigned. These posts are of post_type=post, not a custom post type.

I linked to and queried for the Volume Taxonomy quite easily . However, I'm stuck when I need to make a URL and query for all posts which belong to Volume-X and Issue-X.

I'd love for the url which lists all posts in Issue-X to be example.com/volume-1/issue-1 (i use volume-1 taxonomy term and issue-1 taxonomy term to perform a query) but cannot figure out how to do this. The query is not an issue, I can do a tax_query with 2 taxonomies, I just cant figure out how to rewrite my url to the appropriate place/page to do the query.

How would I accomplish a url structure of example.com/volume-1/issue-1/ or example.com/volume1/issue/1 and have it list posts which have a taxonomy term of volume-1 and issue-1? Again, these posts are regular wordpress posts, not custom_posts. Hopefully, an answer would allow for pagination as well?

i've been struggling with this for a week or so, really need to put this one to bed :(

function add_custom_taxonomies() {


// Add new "Locations" taxonomy to Posts
register_taxonomy('volume', 'post', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => false,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Volume', 'taxonomy general name' ),
'singular_name' => _x( 'Volume', 'taxonomy singular name' ),
'search_items' =>  __( 'Search Issues' ),
'all_items' => __( 'All Issues' ),
'parent_item' => __( 'Parent Volume' ),
'parent_item_colon' => __( 'Parent Volume:' ),
'edit_item' => __( 'Edit Volume' ),
'update_item' => __( 'Update Volume' ),
'add_new_item' => __( 'Add New Volume' ),
'new_item_name' => __( 'New Volume Name' ),
'menu_name' => __( 'Volume' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'volume', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/locations/"
'hierarchical' => false 
),
));

register_taxonomy('issue', 'post', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => false,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Issue', 'taxonomy general name' ),
'singular_name' => _x( 'Issue', 'taxonomy singular name' ),
'search_items' =>  __( 'Search Issues' ),
'all_items' => __( 'All Issues' ),
'parent_item' => __( 'Parent Issue' ),
'parent_item_colon' => __( 'Parent Issue:' ),
'edit_item' => __( 'Edit Issue' ),
'update_item' => __( 'Update Issue' ),
'add_new_item' => __( 'Add Issue Volume' ),
'new_item_name' => __( 'New Issue Name' ),
'menu_name' => __( 'Issue' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array( 'slug' => 'issue', 'with_front' => false )


));

} add_action( 'init', 'add_custom_taxonomies', 0 );

share|improve this question
    
Post the code you've been working on. However, the URL you are aiming for looks like one prone to collision with other rules. –  s_ha_dum Jun 11 '13 at 23:56
    
I added the code in my functions.php which registers the Taxonomies. –  mmundiff Jun 13 '13 at 16:46

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.