How To

Add Custom Base URL to post Links

add_filter( ‘post_link’, ‘add_custom_base_to_post_links’, 10, 3 );

function add_custom_base_to_post_links( $post_link, $post, $leavename ) {
if ( ‘post’ != $post->post_type || ‘publish’ != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( ‘/’ . $post->post_name . ‘/’, ‘/your_custom_base/’ . $post->post_name . ‘/’, $post_link );
return $post_link;
}