flush_rewrite_rules() should be called very early within the WordPress initialization. The reason is that the entpoints cannot be changed afterwards.
A solution could look like this:
function updateMySlugOption($old_value, $value, $option) {
if( $old_value != $value ) {
set_transient('update_slugs', 1);
}
}
add_action( 'update_option_mySlug', 'updateMySlugOption', 10, 3);
function update_slugs() {
if( get_transient('update_slugs') ) {
flush_rewrite_rules();
delete_transient('update_slugs');
}
}
add_action('init', 'update_slugs');
Related Posts:
- How to call a plugin function from index.php
- Rewriting every 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?
- Custom url structure for custom template
- Add a Custom Permalink option in the Permalink Admin Screen?
- How to get the permalink of a page when loading my plugin
- How do I add a custom sub menu menu under Woo-commerce marketing?
- How to change custom post type pemalink Hierarcy
- Modifying Author Link to add Author Meta in URL
- SEO Friendly URL on dynamic product page produced via shortcode
- Perform internal redirect in WordPress?
- How to get the permanent link in a plugin?
- Add_rewrite_endpoint doesn’t work with post name permalink structure
- How to embed a new string in url?
- Make get_permalink() work outside the Loop using filters
- help intercepting save_post through plugin
- WordPress Frontend Page using Plugin
- Child theme modifications not showing up
- Create new page in wordpress plugin which doesn’t exist
- 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
- claim a permalink and all sublinks in plugin
- Notify Admins about Plugin Merge
- Adding Featured Image in Post List
- Why does including a file in theme’s functions.php not work?
- WooCommerce – Call to undefined function is_woocommerce()
- OEmbed from Pinterest
- Should I use RIPS tool to test my themes and plugins?
- Add Top-Level Menu that opens URL
- Change the name of an installed plugin
- Issue with post request to admin-post.php
- action-scheduler vs wp-background-processing
- Do you clean up your self-written plugins’ at deactivation?
- like to keep reading plugin
- Check if email address exists front end with AJAX in a plugin
- Global matrix for shortcodes/content for every page
- How to add class in plugin only for network site?
- Plugin Development sqlite or WordPress’ database
- How to write a plugin to add users to a mail list
- WordPress plugin for activating other plugins
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- AJAX search posts and pages
- Combine scripts from all extensions of the plugin when an extension is activated
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Checkbox conflict in my custom plugin admin page
- How to create a custom shortcode based on the layout?
- Can a Plugin Override New User Default Role Type
- How to let user store a file in plugin directory but not have it get deleted on update?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Plugins ignored a line breaks or tag in the WordPress comment functions
- How to get path or root of plugin folder, not file or dir?
- Change letters for day name
- (WordPress 5.8.3) Function.php or a plugin for better performance? [duplicate]
- What is the easiest way to rename a plugin (and also avoid plugin updates)
- Sanitize $_GET variable when comparing
- Where can I save plugin data?
- show my own admin_notices after a post has been published
- How to add a WordPress Nonce for this form to avoid CSRF
- How to add update function to plugin without adding it to https://wordpress.org/plugins/ [closed]
- Plugin option default value
- How to edit link for comment count
- Integrating Custom Database with WordPress
- TranslatePress | secondary language category/sub-category not working correctly “`/%category%/%postname%/“`
- How to get the custom field value using SQL query
- specific rows style for in custom list table using WP_List_Table
- How to add the search page link to the anchor tag?
- Need to know if my approach to designing a geneaology plug-in for wordpress makes sense
- Creating one user access account for all the multiple sites
- return bbp_get_topic_author_id as integer
- I am Getting Sorry, no posts matched your criteria on form submit only for certain page [duplicate]
- wpdb update method is updating but not refreshing the current page data
- Dynamic input fields in WordPress Plugin
- WordPress Widget: Is it possible to make the form dynamic without updating?
- Change default url to plugin custom post type
- Creating a user ‘add custom field’ section
- How to show post attachment image
- Can a developer adopt a plugin marked as “not updated in over 2 years”?
- Making a Custom Post Type Publish Loop
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- Someone Comment 1000 times in a Day in My WordPress Site, What Can i Do
- get_option returning a different value from what’s saved
- Plugin: Custom menu item problem
- Getting warning of Missing argument 2 for wpdb::prepare()
- How do I set register_meta for a specific CPT?
- How to Enfroce Domain Licensing Limits? [closed]
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Update Content for a Custom Block Toolbar Button
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Wrong block appender button showing
- Uncaught Error: Cannot use object of type stdClass while showing the list using WP_List_Table
- Submitting form to admin-post.php WordPress
- WordPress Throwing Deprecated Errors on its own Files