How to Setup Permalink Structure via functions.php in WordPress


website’s URL is Permalink, Have your website in wordpress and want to customize permalink structure via code, So Open your active theme’s folder and paste given code in functions.php file.

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

When you paste this, then your new posts and uploaded posts URL in with title name like