Chúng tôi cần xóa đường dẫn danh mục sản phẩm ở Woo của WordPress thì làm sao ? việc loại bỏ sẽ tốt hơn cho SEO danh mục sản phẩm. Nay mình kiếm được code từ các bên và ghép lại để nó hoàn thiện hơn.
Đường dẫn của bạn có dạng : domain.com/danh-muc-san-pham/san-pham
Bạn muốn loại bỏ chữ : danh-muc-san-pham trên đường dẫn link url đó ? hay copy code sau vào Functions.php rồi cập nhật lại đường dẫn tĩnh nhé.
add_filter( 'term_link', 'devwp_product_cat_permalink', 10, 3 ); function devwp_product_cat_permalink( $url, $term, $taxonomy ){ switch ($taxonomy): case 'product_cat': $taxonomy_slug = 'danh-muc-san-pham'; //Thay bằng slug hiện tại của bạn. Vào đường dẫn tĩnh kiểm tra rồi thay vào danh-muc-san-pham if(strpos($url, $taxonomy_slug) === FALSE) break; $url = str_replace('/' . $taxonomy_slug, '', $url); break; endswitch; return $url; } // Add our custom product cat rewrite rules function devwp_product_category_rewrite_rules($flash = false) { $terms = get_terms( array( 'taxonomy' => 'product_cat', 'post_type' => 'product', 'hide_empty' => false, )); if($terms && !is_wp_error($terms)){ $siteurl = esc_url(home_url('/')); foreach ($terms as $term){ $term_slug = $term->slug; $baseterm = str_replace($siteurl,'',get_term_link($term->term_id,'product_cat')); add_rewrite_rule($baseterm.'?$','index.php?product_cat='.$term_slug,'top'); add_rewrite_rule($baseterm.'page/([0-9]{1,})/?$', 'index.php?product_cat='.$term_slug.'&paged=$matches[1]','top'); add_rewrite_rule($baseterm.'(?:feed/)?(feed|rdf|rss|rss2|atom)/?$', 'index.php?product_cat='.$term_slug.'&feed=$matches[1]','top'); } } if ($flash == true) flush_rewrite_rules(false); } add_action('init', 'devwp_product_category_rewrite_rules'); // taxomony 404 // add_action( 'create_term', 'devwp_new_product_cat_edit_success', 10, 2 ); function devwp_new_product_cat_edit_success( $term_id, $taxonomy ) { devwp_product_category_rewrite_rules(true); }
Tagged with: remove category product woocommerce, xóa url category sản phẩm woo
Despite recent reports that the standard corporate web risk is normally raising, investigations experience revealed that normally fail to...
A virtual data bedroom is a web-affiliated repository of documents and also other information utilized for business transactions. It is...
Today's board of administrators software applications are designed to make the do the job of the company more efficient. They get rid of the need...
Custom research papers are one of the most cost effective alternatives available in the industry today. The most significant element of the papers is...
Thêm mục đăng bài trong danh mục sản phẩm " Add editor to Wordpress WooCommerce Product Category Page ", nhiều người đang cần...
Bình luận bài viết
Đăng nhập để bình luận và xem các bình luận khác.