How to hook into a change to the permalink structure
-
I’m writing a plugin, and need a function to run every time the permalink structure is changed. The function will calculate the new permalink for one of my pages.
The obvious thing seemed to be:
add_action('update_option_permalink_structure', 'update_podcast_url')
The problem is that when
update_podcast_url
callsget_permalink
, it returns the old permalink, not the new one. Using$wp_rewrite->flush_rules()
beforeget_permalink
doesn’t work, either.I can’t use
add_action('generate_rewrite_rules', 'update_podcast_url')
because this doesn’t trigger if permalinks are turned off, only if the structure is changed.Any suggestions?
- The topic ‘How to hook into a change to the permalink structure’ is closed to new replies.