Hi @dkanika,
How was the code specifically added? Did you use a child theme or an additional plugin?
I accidentally made a typo in the last line of code, so if it was executed, it should result in a fatal PHP error. Just in case, here is the corrected version:
function pm_random_string_field( $default_uri, $native_slug, $post, $slug, $native_uri ) {
// Do not affect native URIs
if ( $native_uri || empty( $post->post_type ) ) {
return $default_uri;
}
if ( false !== strpos( $default_uri, '%random%' ) ) {
$length = 11;
$random_string = wp_generate_password( $length, false );
$default_uri = str_replace( '%random%', $random_string, $default_uri );
}
return $default_uri;
}
add_filter( 'permalink_manager_filter_default_post_uri', 'pm_random_string_field', 3, 5 );
add_filter( 'permalink_manager_do_not_append_slug', '__return_true' );
The snippet itself will work only for posts, pages and custom post type items that were published after the code was active. All URLs generated prior to inserting the code will be unaffected.