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.

In my plugin I have a custom post type with a slug of 'ready-to-wear' and I have a custom taxonomy called 'seasons' associated with it.

The odd thing is that this url with query works:

http://dev.catwalkyourself.com/ready-to-wear/?seasons=autumn-winter-2012-2013-en

but the same one with custom permalink doesn't:

http://dev.catwalkyourself.com/ready-to-wear/seasons/autumn-winter-2012-2013-en

It throws a 404 error. You can try pasting the links yourself.

Here is my relevant plugin code:

Here is where the custom post type is registered

$post_types = array();

    $post_types['rtw'] =  $args = array(
        'labels' => array(
            'name' => __('RTW Collections'),
            'singular_name' => __('Ready to Wear Collection'),
            'add_new' => __('Add new RTW collection'),
            'add_new_item' => __('Add a new show to the RTW collection'),
            'edit_item' => __('Edit Collection'),
            'view_item' => __('View Collection'),
            'search_items' => __('Search Ready to Wear Collections'),
            'not_found' => __('No RTW Collections found'),
            'not_found_in_trash' => __('No RTW Collections found in trash')
        ),
        'query_var' => 'rtw_collections',
        'supports' => array('title', 'editor', 'thumbnail', 'author', 'comments'),
        'has_archive' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'taxonomies' => array('seasons','city'),
        'rewrite' => array(
            'slug' => 'ready-to-wear',
            'with_front' => false
        ),
        'public' => true,
        'menu_position' => 6
    );

Here is where the taxonomy is configured:

$taxonomies = array();

    $taxonomies['seasons'] = array(
        'query_var' => 'seasons',
        'rewrite' => array(
            'slug' => 'seasons',
            'with_front' => false
        ),
        'single_value' => true,
        'required' => true,
        'labels' => array(
            'name' => __('Seasons'),
            'singular_name' => __('Season'),
            'edit_item' => __('Edit Season'),
            'update_item' => __('Update Season'),
            'add_or_remove_items' => __('Add or remove seasons'),
            'new_item_name' => __('Add new Season'),
            'all_items' => __('All Seasons'),
            'search_items' => __('Search Seasons'),
            'popular_items' => __('Popular Seasons'),
            'separate_items_with_commas' => __('Separate Items with commas'),
            'choose_from_most_used' => __('Choose from most used Seasons')
        )
    );

and here is the call to register_taxonomy:

foreach ($taxonomies as $taxonomy => $arr) {
            register_taxonomy($taxonomy, null, $arr);
        }

I have tried:

  • Flushing the permalinks repeatedly
  • Setting 'with_front' true and false repeatedly
  • add flush_rewrite action to my functions.php

Unfortunately, none of these work. Please help me out.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I solved this issue by making sure that the calls to register my taxonomies were placed before the calls to registering my custom post types. Weird but it works!

share|improve this answer
1  
OMG thank you for this!!! i was tearing my hair out. No idea why that fixed all the mysterious issues I've been having but it did. THANKS! –  Michelle Jan 23 at 22:57
add comment

Add

flush_rewrite_rules();

After your register_taxonomy() function

share|improve this answer
2  
Please add an explanation to your answer: why could that solve the problem? –  toscho 9 hours ago
1  
Flushing rewrite rules on every request comes with a huge performance drawback. –  kaiser 8 hours ago
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.