是的。但是,請閱讀這篇文章第一https://docs.woocommerce.com/document/removing-product-product-category-or-shop-from-the-urls/
您可以通過更改此:
您可以更改產品類別基地設置固定鏈接>永久鏈接>可選>產品類別基地= ./(型./ )。
確保您沒有任何頁面,張貼或附件與分類頁面具有相同的名稱(slug),否則它們會發生碰撞,代碼將無法工作。
安裝並激活下面的插件: (欲瞭解更多信息,請參閱https://timersys.com/remove-product-category-slug-woocommerce/)
`
<?php
/*
Plugin Name: Remove product-category slug
Plugin URI: https://timersys.com/
Description: Check if url slug matches a woocommerce product category and use it instead
Version: 0.1
Author: Timersys
License: GPLv2 or later
*/
add_filter('request', function($vars) {
global $wpdb;
if(! empty($vars['pagename']) || ! empty($vars['category_name']) || ! empty($vars['name']) || ! empty($vars['attachment'])) {
$slug = ! empty($vars['pagename']) ? $vars['pagename'] : (! empty($vars['name']) ? $vars['name'] : (!empty($vars['category_name']) ? $vars['category_name'] : $vars['attachment']));
$exists = $wpdb->get_var($wpdb->prepare("SELECT t.term_id FROM $wpdb->terms t LEFT JOIN $wpdb->term_taxonomy tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'product_cat' AND t.slug = %s" ,array($slug)));
if($exists){
$old_vars = $vars;
$vars = array('product_cat' => $slug);
if (!empty($old_vars['paged']) || !empty($old_vars['page']))
$vars['paged'] = ! empty($old_vars['paged']) ? $old_vars['paged'] : $old_vars['page'];
if (!empty($old_vars['orderby']))
$vars['orderby'] = $old_vars['orderby'];
if (!empty($old_vars['order']))
$vars['order'] = $old_vars['order'];
}
}
return $vars;
});`
欲瞭解更多信息,請參閱https://timersys.com/remove-product-category-slug-woocommerce/
你有沒有ked設置 - >固定鏈接? –
@Bhagya Shree不推薦,閱讀此https://docs.woocommerce.com/document/removing-product-product-category-or-shop-from-the-urls/ – kebir