✨ Professional WordPress development, custom website builder, efficient on-line, cooperate and enjoy optimization services! 🚀
add_filter( 'register_post_type_args', 'change_woo_product_slug', 10, 2 );
function change_woo_product_slug( $args, $post_type ) {
if ( 'product' === $post_type ) {
// 设置 rewrite slug 为单数 product,with_front 控制是否保留前缀,比如 /shop/
$args['rewrite'] = array(
'slug' => 'product',
'with_front' => false,
'feeds' => true,
'pages' => true,
);
}
return $args;
}
After modifying the code, be sure to go to the Settings→Fixed Links page and click "Save Changes" to refresh the WordPress rewrite rules, otherwise the new link will not take effect.