Skip to content

Instantly share code, notes, and snippets.

@smileBeda
Created December 9, 2020 12:33
Show Gist options
  • Save smileBeda/d10e550864003654ebf9a3068f354bc2 to your computer and use it in GitHub Desktop.
Save smileBeda/d10e550864003654ebf9a3068f354bc2 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment