Last active
August 29, 2015 13:56
-
-
Save wpsmith/8935396 to your computer and use it in GitHub Desktop.
PHP: Adjust the rewrite of a registered post type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a further explanation, see the tutorial here: http://wpsmith.net/2013/wp/use-registered_post_type-hook-to-modify-post-type-registration/