Set permalink settings from functions.php

Use this snippet to change the permalink settings from your functions.php file instead of in the admin area. The .htaccess mod_rewrite it is still necessary.

Code Snippet:

<?php
// set permalink
function set_permalink(){
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%postname%/');
}
add_action('init', 'set_permalink');
?>

Posted in Pure hacks