try this
add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );
add_filter( 'query_vars','my_insert_query_vars' );
function my_insert_rewrite_rules( $rules )
{
$newrules = array();
$newrules['(.+?)/custom_post_type_slug/(.+?)/?$'] = 'index.php?post_type=custom_post_type_slug&dynamic_string=$matches[1]&custom_post_type_slug=$matches[2]';
return $newrules + $rules;
}
function my_insert_query_vars( $vars )
{
array_push($vars, 'dynamic_string');
return $vars;
}
Related Posts:
- Custom pages with plugin
- How to call a plugin function from index.php
- Rewriting every url
- Add rewrite rule to permalink structure
- add_rewrite_rule, plugin activation and plugin deactivation
- What is the best way to output plugin result in certain url
- Passing URL parameters to WordPress pages and pretty url
- Publish Post After Click On A Link
- How to get the custom page get_permalink?
- Does flush_rewrite_rules() remove all rules added by other plugins as well as mine?
- Add_rewrite_rule doesn’t add custom url in plugin
- Custom url structure for custom template
- Add a Custom Permalink option in the Permalink Admin Screen?
- flush_rewrite_rules() not working on plugin activation
- How to get the permalink of a page when loading my plugin
- Rewrite url without flushing the database?
- Best way to hook a custom url?
- How to Create a Custom Plugin Permalink
- How do I add a custom sub menu menu under Woo-commerce marketing?
- How to change custom post type pemalink Hierarcy
- Plugin appends ugly URL string to index
- Modifying Author Link to add Author Meta in URL
- Perform internal redirect in WordPress?
- Plugin generated taxonomies’ permalinks with custom placeholders
- How to get the permanent link in a plugin?
- flush_rewrite_rules() not working with update_option_{$option}
- Add_rewrite_endpoint doesn’t work with post name permalink structure
- How to rewrite URL and get the values?
- Do rewrites added with add_rewrite_rule() persist after plugin deletion?
- Make get_permalink() work outside the Loop using filters
- help intercepting save_post through plugin
- TranslatePress | secondary language category/sub-category not working correctly “`/%category%/%postname%/“`
- Hidden permalink different from displayed permalink
- WordPress Frontend Page using Plugin
- Child theme modifications not showing up
- WordPress rewrite rule depend on meta values not ids
- Create new page in wordpress plugin which doesn’t exist
- one url for all pages
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- Changing author slug for a custom role without using plugin
- Custom author page for custom role
- Custom role not listed
- Is it possible to change plugin’s Admin Panel Url?
- Coming soon pages with rest of site in maintenance mode
- Change default url to plugin custom post type
- Custom pages with plugin
- Apache rewrite rules and wordpress problem
- claim a permalink and all sublinks in plugin
- Trying to Find the PHP File/Function that Handles a Specific Form Action URL
- Help Needed: Issue with Change Permalink on DirectoryPress Listing Pages
- Getting a List of Categories for Use in a Plugin?
- Changing labels of status filters for post grid
- Can we use a webservice with WordPress?
- Where to call add_shortcode function in WordPress Plugin Boilerplate?
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Changed permalink structure. Need help with redirecting old posts
- Change permalink structure hidden button edit
- How to load plugin after page is loaded – pagespeed issues
- Open Post Thumbnail in New Child Theme File in WordPress
- How to pull code snippet from functionality plugin?
- How to use get_theme_mod in gutenberg editor wordpress?
- Why slash is removed after domain?
- MITM risk of not sanitizing?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- How to keep users unique id stored in session in addition to IP in WordPress plugin?
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- Where should I save an API key of my user when installing my plugin?
- How to make a customize role and view a specific plugins base on that role?
- Reusable functions and tools (Framework)
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- React JSX in WordPress Plugin Development
- My plugin wants to update another plugin
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Where (or when) should I register a new taxonomy?
- Woocommerce plugin for minimum order and add-to-card-step
- Self deactivate plugins after an action occurs
- How to get current post user id
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Issue with adding count to “subsubsub” aka quick links on custom_post_type
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- How to slice an array using posts_per_page? [closed]
- White page on custom plugin option submit
- Simple ajax call not working in wordpress plugin
- Plugin version is not showing up in wordpress.org plugin directory
- Do action only on certain front end pages?
- Change plugin main file name (that is currently in the repo)
- Create dynamic page content from custom WordPress plugin page
- Plugin Options Not Saving to Database in WP 4.5
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- How to create ‘import dummy data’ option in custom wordpress plugin
- Call to a member function have_posts() on a non-object on normal loop
- JS Support Ticket – Auto create WP account
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- Load custom PHP on a custom URL via a plugin