Help with a TV series Rewrite structure

Not sure if this is possible, but bear with me. I think I am halfway there.

First a little background: I’m using the build in hierarchy in WordPress to form relationships between post types. I have a post type called series that holds info on a TV series. I have another post type called content that has info on specific episodes and I use the built in post_parent field on the posts data table to point to a series.

Read More

So basically, I’m trying to do a rewrite/permalink structure similar to this for content:

http://website.com/%series-name%/%content-type%/%postname%

content-type is a taxonomy attached to content that has a few terms; episode, movie and special.

My idea to prevent rewrite collisions was to use this code, inspired by a previous question I had asked here

add_filter( 'rewrite_rules_array', 'content_rewrite_rules',10,1);
function content_rewrite_rules( $rules ) {
        $custom_rules = array();
        $type_terms = get_terms('veda_content_type', array('hide_empty'=>false));
        if(!is_wp_error($type_terms) && sizeof($type_terms) > 0) {
            foreach ($type_terms as $term) {
                $custom_rules['([^/]+)/'.$term->slug. '/([^/]+)/?$'] = 'index.php?post_type=veda_content&series_name=$matches[1]&pagename=$matches[2]';
            }
        }

        return array_merge($custom_rules , $rules);
    }

Using the rewrite analyzer, it seems that it sorta works, except it shows that the series_name query_var is crossed out in red and I’m not sure what that means.
Rewrite 1
My question is: is there another, more efficient way to create the permalink that I want? Also, what the cross out mean?

EDIT: I’m trying to see if the rewrite works and my server is giving me bad request errors

Related posts

Leave a Reply

1 comment