WordPress.org

Ready to get started?Download WordPress

Forums

How to hook into a change to the permalink structure (1 post)

  1. Mark Barnes
    Member
    Posted 5 years ago #

    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 calls get_permalink, it returns the old permalink, not the new one. Using $wp_rewrite->flush_rules() before get_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?

Topic Closed

This topic has been closed to new replies.

About this Topic