Skip to content

Instantly share code, notes, and snippets.

@BeardedGinger
Created November 30, 2016 19:17
Show Gist options
  • Save BeardedGinger/8396195d4a5924c0264f2dacfa330296 to your computer and use it in GitHub Desktop.
Save BeardedGinger/8396195d4a5924c0264f2dacfa330296 to your computer and use it in GitHub Desktop.
public
<?php
add_filter( 'register_post_type_args', 'lc_change_registered_post_type_slug', 10, 2 );
/**
* Change the slug for a registered post type.
*
* @param array $args Array of arguments for registering a post type.
* @param string $post_type Post type key.
*/
function lc_change_registered_post_type_slug( $args, $post_type ) {
// Make sure we're only modifying our desired post type.
if ( 'post_type' != $post_type )
return $args;
$args['rewrite'] = array( 'slug' => 'new-slug' );
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment