WordPress Change Default Post URL

If we need to add custom slug in URL then used below snippet to change it. Add code in functions.php

function filter_post_link($permalink, $post) {
	if ($post->post_type == 'post') {
        return '/blog/'.$permalink;
	}   
    return $permalink;
}
add_filter('pre_post_link', 'filter_post_link', 10, 2);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s