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
- Best way to initiate a class in a WP plugin?
- How to safely sanitize a textarea which takes full HTML input
- How to Remove Certain Screen Options and Meta Boxes from add/edit post type?
- Why activate_plugin is not working in register_activation_hook
- Custom Filter in WordPress to modify footer information via plugin?
- WP WC CLI – WooCommerce setup store with wp-cli [closed]
- Editor access to plugin settings
- How to use a Must-Use plugin to hide a regular one and to hide itself?
- Shortcode display outside the div
- Insert code after tag without using functions.php?
- Extend the Admin Post/Edit page
- Unable to load stylesheets and scripts to plugin settings page
- Can wp_script_is used in pluginA check if a script is being enqueued/registered from pluginB?
- Licensing of freemium plugin
- $wpdb working with ajax but showing ajax error instead of success
- Default Plugin Settings Not Writing to Database
- Create a custom page template inside my wordpress plugin
- White page on custom plugin option submit
- How to add Internationalization in WordPress using Javascript/React?
- creating html reusable blocks via shortcodes
- I want to auto populate data in three fields if one drop down is selected
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- How can I change the meta_key for a particular piece of information?
- WordPress REST API Plugin Development – Add Custom Endpoint
- Hook into the rendering of a WordPress Template
- Save user total active time after login in wordpress [closed]
- WordPress gtag.js with User ID tracking
- Calling a save function from a “submit” button
- Select Form Element Not Saving from Plugin Options
- My widget won’t update its values when save is clicked
- Gutenberg default attributes are empty when accessing in edit
- How to create admin setting for this small plugin
- How to fix caching issue in PHP data from database
- Adding shortcodes to multiple pages with function
- SASS not showing in customized preloader plugin
- How to securely controlling data without keeping it in postmeta?
- Get a list of Product Categories inside a loop
- Can you develop themes and plugins while using the hosting services BlueHost? [closed]
- wordpress ajax pagination object value does not change
- Google analytic issue in wordpress
- How to insert category name above post title in a featured pages plugin?
- What’s the preferred method of writing AJAX-enabled plugins?
- wp_update_post call really slow when official Facebook plugin is installed
- How to set-up multiple cron task with wp_schedule_event so that they do not overlap?
- How to get the real address from a url (permalink)
- Plugin version number after code rewrite [closed]
- Plugin Block at the backend of every page or post
- Getting 400 Error in wordpress website
- How to provide page_template path in custom plugin using WordPress
- How to add a react element into the DOM node (only on the user-interaction like on click) without using the state?
- WordPress theme development – the template dropdown in Pages and disappeared