Configure Permalinks Using a Theme or a Plugin

To configure permalinks using a theme or a plugin, you can use this snippet:

function snippet_set_permalink(){
    global $wp_rewrite;
    $wp_rewrite->snippet_set_permalink_structure('/%postname%/');
}

add_action('init', 'snippet_set_permalink');