Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/8935396 to your computer and use it in GitHub Desktop.
Save wpsmith/8935396 to your computer and use it in GitHub Desktop.
PHP: Adjust the rewrite of a registered post type.
<?php
add_action( 'registered_post_type', 'gs_projects_rewrite', 10, 2 );
/**
* Modify registered post type menu label
*
* @param string $post_type Registered post type name.
* @param array $args Array of post type parameters.
*/
function gs_projects_rewrite( $post_type, $args ) {
if ( 'project' === $post_type ) {
global $wp_post_types;
$permastruct_args = $args->rewrite;
$permastruct_args['feed'] = $permastruct_args['feeds'];
add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%/%project_category%", $permastruct_args );
}
}
@wpsmith
Copy link
Author

wpsmith commented Feb 11, 2014

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