WordPress.org

Ready to get started?Download WordPress

Forums

Must call $wp_rewrite after update_options('permalink_structure') ??? (3 posts)

  1. vestaviascott
    Member
    Posted 4 years ago #

    After calling an update_option('permalink_structure', '/%postname%/') via script in functions.php, is it necessary to then call a $wp_rewrite as indicated below?

    // Flush rules to pick up the new page.
    $wp_rewrite->init();
    $wp_rewrite->flush_rules();

    If so, it the purpose of the rewrite to insure that the .htaccess file gets updated?

    I ask this because just after executing the function, my pages return 404's even though the permalinks_options.php reports that the permalink is indeed set to custom: '/%postname%/')

    However, I have to manually hit "Save Changes" on the permalink options page to make it stick. I'm wondering if the fix is to add the rewrite code above, or am I missing something?

  2. vestaviascott
    Member
    Posted 4 years ago #

    wp_rewrite does not appear to have any effect. Users still have to manually click "Save Options" on the permalinks screen.

    I suppose I will run firebug on that page during the update to see what's getting set that update_options is apparently missing.

    This would appear to be a bug in update_options when the option being updated is permalink_structure.

    Anyone disagree?

  3. nycphotography
    Member
    Posted 4 years ago #

    I'm thinking your error was in setting the option directly in the database rather than using the

    set_permalink_structure($permalink_structure)

    function as documented here

    http://codex.wordpress.org/Function_Reference/WP_Rewrite

Topic Closed

This topic has been closed to new replies.

About this Topic