How to Set Permalink Settings From functions.php in WordPress 4.4 – 2017

The URLs of the articles and post you distribute on your WordPress site are known as permalinks. Permalinks are what individuals go into their browsers to view one of your pages. They are likewise what web indexes and different sites use to connection to your site. Because of this, it is imperative that they are taken seriously.

You can change the structure of your permalinks whenever however doing this affects the URL of your pages. This can bring about your web index movement and referral activity to drop impressively as guests are given 404-page mistakes rather than the page they needed to see.

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.

<?php
// set permalink
function set_permalink(){
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%postname%/');
}
add_action('init', 'set_permalink');
?>
How to Set Permalink Settings From functions.php in WordPress 4.4 – 2017
5 (85%) 82 votes