• I have written a plugin for our website, this plugin sets a custom rewrite on activation as it pulls data from an external source, saves to the database in a custom table and displayed using a /item/ (page-item.php) template in the form of website.com/item/itemid/.

    The site has many other plugins installed and one of these keeps flushing the rewrites (my guess is that it is Yoast SEO) making all of the /item/itemid/ pages break.

    Is there a way to check whether a rewrite is active? I’m thinking that if there is, I could write a scheduled task to run every 5 minutes, check if the rewrite is active, if not, set it again.

    Thanks

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could check the global $wp_rewrite array from a very late action hook and try to locate your rule. However, rewrite rules are also flushed every time you visit the permalinks settings screen. Don’t blame Yoast for flushing ?? Flushing rules should not disable your rule if it was added correctly to start with. It is possible a plugin conflict is disabling your rule anyway. To check, disable all plugins except the code adding your rule. Visit the permalinks screen to cause a rewrite flush. If your rule still works, you’ve apparently added it correctly. Restore plugins, one at a time, flushing rules and testing after each. When your rule fails again, the last added plugin is the cause.

    Periodically adding your rule back in is a poor solution that wastes server resource. Get it added correctly without conflict and there will never be a need to repeatedly add it back.

Viewing 1 replies (of 1 total)
  • The topic ‘Test if my rewrite is still set’ is closed to new replies.