How to Change Permalink Structure using Code | WordPress Solution

You can easily change your blog post’s permalink structure using code. If you want to change so paste given code in your theme’s functions.php file and take new changes in permalink structure.

How To Change Permalink Structure

  1. Open active theme’s functions.php file.
  2. Paste code and click on SAVE button.

Code – 

add_action( 'init', function() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%postname%-%post_id%' );
} );

Hope this code work fine. Have another doubt so contact me via contact us section. Thank You