Skip to content

Instantly share code, notes, and snippets.

@abdulawal39
Created January 26, 2023 18:01
Show Gist options
  • Save abdulawal39/23ce77a28c6a05c73beac53aa4908ac0 to your computer and use it in GitHub Desktop.
Save abdulawal39/23ce77a28c6a05c73beac53aa4908ac0 to your computer and use it in GitHub Desktop.
Change the slug of pdf viewer for wordpress from pdfviewer to anything you prefer. Put the code below in your active theme's fuctions.php file
if( ! function_exists( 'themencode_change_pdfviewer_slug' ) ):
add_filter( 'register_post_type_args', 'themencode_change_pdfviewer_slug', 10, 2 );
function themencode_change_pdfviewer_slug( $args, $post_type ) {
if ( 'pdfviewer' === $post_type ) {
$args['rewrite']['slug'] = 'pdfs'; // replace pdfs with your preferred slug
}
return $args;
}
endif;
@abdulawal39
Copy link
Author

Make sure to navigate to Settings > Permalinks Page once after adding this code for the change to be propagated completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment