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
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Customizing subject in comment notification e-mails
- Add content to /wp-admin/plugin-install.php admin screens
- Need a function for changing saved post_date or post_date_gmt to relative time in wordpress
- Change Permalinks Structure to a Sequential Number for Each Post?
- Plugin child folder?
- merging an array to an existing array using add_filter
- How do I store information in a dynamic block in WordPress?
- Is it possible to set up multistore in Woocommerce? [closed]
- How to generate video out of images via WordPress plugin
- How to slice an array using posts_per_page? [closed]
- Get plugin option in another PHP file
- woocommerce payment gateway callback not firing [closed]
- How to export post 2 posts WordPress plugin data [closed]
- Customization API for plugin development
- Adding Font Awesome to WP Plugin
- Display custom content using page.php from theme
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- How to customize a title by passing query string?
- Translations for my plugin don’t show up
- Translation issue with global variables
- Is there a better way of handling AJAX requests in WordPress?
- how to add a comment button to be displayed only for the posts in the home page [closed]
- How to add category and subcategory in WordPress custom code?
- Custom Fields for Page Edits
- How to make sure settings are not lost when plugin is updated?
- How Can i import plugin option?
- How to override any plugin file in the child theme
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- Custom Plugin Update
- How do I stop plugins and themes from getting updated in a new plugin?
- How come W3TC is allowed to host premium code in the WordPress repo?
- Passing function into add_action always returns the first argument
- Members-only page, but accessible via sharable link
- plugin not hooking to my custom hook
- Populate select option with JSON file
- Enahanced search for edit.php and custom post type
- API Functions to Register and Show WordPress List Tables
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- How to Add Jquery FullCalendar in wp plugin in admin
- Ajax, jQuery and WordPress
- Unable to show 4 products in a row
- 404 not found problem with URL rewrite custom category
- WordPress check box unchecked on null value ternary operator [plugin development]
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- How to provide page_template path in custom plugin using WordPress
- WordPress custom block: Link saved in database not retrieved when editing post
- Accessing Correct Database to Create REST API Endpoint
- Detect if user is on the specific page in WordPress
- A multi-section WordPress store [closed]