Prepend regular Posts with custom slug, without affecting Custom Post Types?

Use the register_post_type_args filter to alter post types registered by code you don’t control.

You can set it for a specific type:

add_filter( 'register_post_type_args', 'wpd_change_post_type_args', 10, 2 );
function wpd_change_post_type_args( $args, $post_type ){
    if( 'turnips' == $post_type ){
        $args['rewrite']['with_front'] = false;
    }
    return $args;
}

Or remove that $post_type check to change it for all custom types.

Leave a Comment

tech