Last active
October 22, 2020 15:14
-
-
Save omniacode/ff0eff76ea759c6695a0d50578a24890 to your computer and use it in GitHub Desktop.
Modify Registered Custom Post Types Args
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
/** | |
* Filter the Products CPT to register more options. | |
* | |
* @param $args array The original CPT args. | |
* @param $post_type string The CPT slug. | |
* | |
* @return array | |
*/ | |
function custom_permalink_mod( $args, $post_type ) { | |
// If not CPT, bail. | |
if ( 'registered-post-type' !== $post_type ) { | |
return $args; | |
} | |
// Add additional CPT options. | |
$custom_args = array( | |
'rewrite' => array( | |
'slug' => 'post-type-slug', | |
'with_front' => false, | |
) | |
); | |
// Merge args together. | |
return array_merge( $args, $custom_args ); | |
} | |
add_filter( 'register_post_type_args', 'custom_permalink_mod', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment