I got an answer on the WordPress forums. Here is the working code for those looking to do something similar:
add_filter( 'post_type_link', 'change_webinar_links', 10, 2 );
function change_webinar_links( $link, $post) {
if ( $post->post_type == 'tribe_events' && tribe_event_in_category('webinar') ) {
$link = trailingslashit( home_url('/webinars/' . $post->post_name ) );
}
return $link;
}
add_action( 'init', 'webinar_rewrite_rule', 5);
function webinar_rewrite_rule() {
add_rewrite_rule( '^webinars/([^/]+)', 'index.php?tribe_events=$matches[1]&post_type=tribe_events&name=$matches[1]', 'top' );
}
Related Posts:
- Need help with add_rewrite_rule
- Rewrite Rule for Multilingual Website, Like qTranslate?
- Custom post type permalink endpoint
- permalink independent on the post’s name stored in the database
- Regex in add_rewrite_tag not accepting OR operators?
- Permalink/Pagination issue: Category base name same as page name
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Using two permalinks for one post
- add_rewrite_rule with 3 or fewer matches?
- Permalinks for WooCommerce Categories and Subcategories
- Redirect short-form URL to long-form URL (post_id to post_id + post_name)
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- How to change URL structure for pagination pages?
- Rewrite url / permalink for default archive – yearly / monthly
- Rewrite rule never matching
- Child pages with same slug
- Permalinks, Rewrites, Get Variables, Oh My!
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Date archive permalink modification
- Change permalink for a single post entry
- rewrite_rule for custom post type doesn’t affect get_permalink
- Add ‘articles’ prefix before blog posts url without affecting pagination
- custom permalink/shortlink with base62 encoded post ID
- When is it a good idea to build a permalink structure from scratch?
- query_vars in plugin not working?
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- Call to a member function add_rule() on a non-object
- I need a custom permalink for my website
- Permalinks: Page Not Found
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- Re-write specific custom post type category URL to go to another page
- Rewrite Rule for default post type
- how to add rewrite rule to wordpress default post type
- Remove custom taxonomy base from URL
- Custom query var rewriting with only variable
- Date Archives’ Permalinks under Category folder
- Custom Permalink
- add_rewrite_rule not working for me
- Is a permastruct possible on pages?
- Using WP Rewrite, but just not “getting it”
- Rewrite rule for a query string
- How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?
- Share same Slug for a Custom Post Type and 2 Taxonomies
- Rewrite CPT permalinks and include WPML language
- Custom permalink leads to index page
- Rewrite rule intended for CPTs gives 404 for pages
- WordPress add_rewrite_tag working for Posts, but not working for Pages
- Need To Add Custom rewrite base url for individual user
- Permalink structure between 2 custom post types and a taxonomy
- Permalinks only for posts
- rewrite rule to redirect to the most recent date permalink
- Custom rewrite rule ignored
- Permalink for PDF of article
- Problems with rewrite rule
- Order custom post type posts by custom field with pretty URL
- Adding URL prefix for foreign language support
- add_rewrite_rule – Page Slug from “/foo-bar/” to “/foo/bar/”
- Add custom query vars to pretty permalinks
- How can you create a Permalink structure on a WordPress site?
- How can I set up a secondary permalink structure?
- permalink and add_rewrite_rule – error 404
- How to Use metada Value in Url and is it possible? [duplicate]
- Safest way to create a custom permalink
- Rewrite Post URL so it is constructed from parent post url & child post url
- rewrite based slug standar post wp
- Adding custom query var to a single post without redirecting to its root slug
- Create different permalinks for same post
- remove SLASH on single_post but KEEP on categories and parent pages
- Fire a code when permalinks updated
- .htaccess to redirect to a wp page
- Flush rewrite rules with scheduled event (cron)
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- Redirect page to homepage, keeping URL
- Add slug to default post permalinks ONLY
- Custom permalink question
- Added a prefix in URL permalink structure but the old structure still working!
- how to have same rewrite rules for 2 different post type?
- Permalink structure /page/page/cpt-post gives 404 with pagination
- Custom Permlinks work, regular page permalinks don’t
- How to change the URL using rewrite rule in wordpress
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Rewrite posts url as they’re all children of a page
- a way to support totally different url structure
- Multiple Permalink Patterns for one page
- create user’s view profile link with username
- Pretty Filter URL
- Where is wordpress redirecting wp-admin/admin/dashboard to wp-admin and how to turn it off
- Added incorrect rewrite rule now getting an error
- Add Custom Pagination Permalink
- Prevent guessing slug
- Why doesn’t WP update my .htaccess file?
- Pretty Permalink for Search Queries Not Working
- ReWrite Permalink to New Permalink Nginx
- WordPress permalink still not working (error or not understood?)
- Only homepage working correctly, 404 error on everything else
- standard post with extra parameter brings permalink problem
- Add additional URL variations for a Post
- Standard Htaccess directives disappear by themselves
- ‘Unsupported Operand Types’ error stemming from taxonomy re-writes with PHP 8.1
- make a new structure tag that does some processing