You’re almost there. You need to add the season
and episode
query vars to the array of recognized vars. Note the small change to your regex as well-
function wpd_add_my_rule(){
add_rewrite_rule(
'^([^/]+)/season-([0-9]+)/episode-([0-9]+)/?$',
'index.php?name=$matches[1]&season=$matches[2]&episode=$matches[3]',
'top'
);
}
add_action( 'init', 'wpd_add_my_rule' );
function wpd_add_query_vars( $query_vars ) {
$query_vars[] = 'season';
$query_vars[] = 'episode';
return $query_vars;
}
add_filter( 'query_vars', 'wpd_add_query_vars' );
You can use get_query_var()
in the template to fetch the values.
Related Posts:
- How to update custom fields using the wp_insert_post() function?
- Get meta_id along with meta_key and meta_value
- How can merge two arrays values in one array and save in database
- Check if user already visited this post today
- Display all meta for a post?
- How to display multiple Post meta_key/meta_values by SQL query
- the_post_thumbnail() based on the Post ID
- How to use multiple query with same meta key
- How to update single value in multi dimensional Post Meta?
- Can I write ‘RewriteCond’ using ‘functions.php’?
- Why is my get_post_meta always empty
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- Compare two meta key values against each other inside the get_posts array?
- How can update custom meta for all posts
- WordPress Rewrite API calls not creating new rules
- Use ajax to update_post_meta
- Newbie question: no index.php? in my plain wordpress permalink
- how to increase custom post value by one most efficiently?
- Batch update a post meta field value of each post in Post Type
- How to Display Image Meta underneath EVERY image in EVERY post
- Change description on specific WooCommerce product status change
- Use WP_Query in shortcode
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Random order of WP_Query results with highest meta value
- Static variable and add_rewrite_rule?
- The text box have space character
- how to remove metadata from the posts of my blog?
- How can I create a list of page titles from custom meta values?
- Trying to remove post thumbnail with plugin
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Apache Fallback instead of add_rewrite_rule
- Performance impact of rewriting WordPress URLs
- Sort custom meta column by other meta value
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Creating user status mode in WordPress
- Need help with Google drive API [closed]
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- Append query string to all URL’s
- custom rewrite rule help! Custom rewrite rules not applying to custom post type
- custom url rewrite for wordpress
- Archive post by meta value + 24hours
- WordPress update_post_meta updating with empty meta_value field [closed]
- Create custom permalinks to show Custom Post Type’s relationship?
- Is it possible to retrieve all posts with a certain value for metadata?
- Get post id within comments loop
- Non-Closing PHP Query in WordPress Loop
- Querying Database with wpdb
- update_post_meta only updating on last loop of foreach
- how to get serialized post meta
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to use two meta_compare in an array?
- How to override url params with rewrite rules vars?
- Remove empty terms from array, sort alphabetically, update back to repeating field
- WordPress loop by meta key that is an array? and how loop multiple arrays
- WordPress yoast seo plugin – parse snippet var in meta description
- How to store multiple custom meta box
- How to add post meta in while loop?
- Add category to post meta
- Update post meta – Custom field does not match meta-key
- Order a WP_Query by meta value where the value is an array
- Save the value of a wp_dropdown_pages
- Add a custom class to the body tag using custom fields
- Define category ID using get_post_meta
- Unable to Call More than One Meta Box Output
- Hide a div when a custom field is empty
- Update value of a associative array with update_post_meta
- Front end file upload returning wrong attachment url
- Post meta select input, if statement
- Reverse Cross-Sells (WooCommerce)
- Remove item from post_meta array via AJAX
- When working with a post, almost all wp_postmeta are deleted
- Post Meta statement?
- Updating Lat and Lng of posts automatically gives sporadic results
- Adding user meta to post meta wp_insert_post() not working
- Efficient way of querying for a “fallback” post?
- WordPress AJAX load post metadata in modal
- Rewrite /keyword1+keyword2.html to search page | .htaccess
- get_post_meta with variable
- add_rewrite_rule questions
- Post from front end form to post_meta
- rewrite_rule – working fine but broken for pagination
- Order by in foreach
- retrieve wordpress post-meta using php not wordpress functions
- Postmeta not saving
- If custom field doesn’t exist, or exists and it’s true show title?
- how to exclude admin page from add_rewrite_rule in wordpress
- get_post_meta is always empty when I use wp_mail
- get_post_meta no longer working
- How to add together (get the sum) a field from all author’s posts
- Metadata on the WP_Post object
- How to display the date under the post title?
- WordPress add parameters with friendly url structure
- How do I get a function to work in single.php
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- How to modify default tags in wp_head()
- Same Custom Post Type Slug and Custom Taxonomy Slug, with hierarchial unique permalink structure
- How to Dynamically Change the author_base URL Slug by Language in WordPress?