Nicolais Tip got me on the right track; Here is the working code:
// add a query_var first
add_filter("query_vars", function($vars) {
$vars[] = "myTheme_podcast_time";
return $vars;
});
add_filter("rewrite_rules_array", function($rules) {
$newRules = array();
$newRules["(.*)/time/([\d|\:]+)s?$"] = 'index.php?name=$matches[1]&myTheme_podcast_time=$matches[2]';
$merged = array_merge($newRules, $rules);
return $merged;
});
And then in single.php
:
$time = get_query_var("myTheme_podcast_time");
// do stuff
Related Posts:
- Dynamic Endpoints
- How to add custom rewrite rule to .htaccess?
- How do I remove a rewrite rule?
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- How to change default page slug?
- Disable wordpress pagination URL rewrite for specific page
- How to use Post Custom Metadata in Post Titles and Post Permalinks
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- rewrite_rule() not preserving the query string
- Need help with rewrite_rules_array
- Why does wordpress still strip my query var?
- When to call `add_rewrite_rule` for safety
- WordPress Network on IIS7/SQL Server – Rewrite Issues
- Custom comments
- Rewrite rules goes away
- add_rewrite_rule again
- Rewrite Rule for Post “Subpage”, with pagination
- Need to make a php file inside theme accessible via url
- Rewrite loading custom template file but is_home() returns true, and there’s no 404
- Rewrite rule for admin-ajax.php
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- WordPress rewrite rules for state and city
- Multiple Permalinks for Same Post
- add_rewrite_rule not working for language specific characters
- Custom rewrite rule
- Single Redirection Rule for Pages and Archive links
- Is it possible to remove feeds from rewrites?
- Flush Rewrite Rules on init or rest_api_init?
- Remove “/page/1” from the URL
- hard flush_rewrite_rules() not regenerating .htaccess
- Rewrite URL – insert custom variables as a directory path
- How to properly rewrite url by custom var
- Rewrite Rules Are Redirecting and Not Passing VARs
- Can’t add external rewrites
- WordPress rewrite rules don’t need ^?
- custom template rewrite
- How to building pretty URLs to reflect category hierarchy?
- WordPress Rewrites – How can I pass a variable to Custom Post Type?
- Monkey Man Rewrite Analyzer says my rule will trigger but it doesn’t [closed]
- Need to add rewrite rule that adds in additional information about the post to url
- add_rewrite_rule is redirecting instead of rewriting url
- Help with Rewrite Rule for Custom Post Type with Query String
- Create Dynamic SEO Friendly URL for Virtual Page
- add_rewrite_rule with query variables
- Rewrite rules automatically for pages using specific template
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- QSA Rewrite Rule
- Help with rewrite rules for two post types
- How to pass url as a parameter in a add_rewrite_rule
- Per Page Permalink Structure for Page Post Type
- Customise particular RSS permalink
- ReWrite rule for files of a previously standalone blog moved to network
- RSS feed rewrite matching wrong rule
- Rewrites rules disappear after a while
- Best way to trigger rewrite rules
- Trouble with question mark in rewrite rule
- Localize URL bases
- WordPress simple Url Rewrite
- What URL rewriting rule should I write to retrieve a var in the URL?
- Custom rewrite rule not working
- Rewriting in wordpress url
- Why is a rewrite rule in wordpress prevent pagination?
- How do I make WordPress revise an .htaccess file a certain way?
- Rewrite custom taxonomy slug – but only parent items
- How can I allow trailing slashes on some URLs without a redirect, but not on others?
- Can’t use a specific custom URL (slug)?
- How to change an existing wordpress page rewrite rule?
- URL rewriting in wordpress using parameters
- Adding the amp url prefix to the beginning
- Rewrite rules – page does not exist
- Rewrite WordPress Url from root to subfolder without moving files
- Rewrite Rules are Redirecting
- How to redirect to a login virtual page?
- Prefix only some posts with a custom prefix
- How do I rewrite URL that has custom parameter
- Help adding custom url, rewrite_rules_array
- Rewrite rule for post as a child of a CPT
- url rewriting on custom post type
- Broken page redirect
- Rewrite rule not redirecting correctly
- Custom taxonomy Rewrite Rule
- add_rewrite Rule
- rewrite rule of post when accessed from archives pages
- I want to add one extra field to my URLs, I’m using Rewrite functions but it doesn’t work
- Font Page overrides rewrites
- Rewrite rule is not working
- How to make a custom route with any-string-part/number-part pointing to an existing page?
- rewrite rule for home/index page
- Post Type Rewrite Custom
- Additional .htaccess rules based on wp page
- URL Rewriting in WordPress
- Rewrite URL variable to custom path
- Rename page URL
- Help with url rewrite
- Wrong rewrite rules
- Rewrite and replace url wp-admin/edit.php and wp-admin/post-new.php
- Programmatically add a custom url route “/category/index.json” to return a collection of posts in json
- WP-Include rewrite directory