Tối ưu hóa đường link,thêm content chân category website WordPress
Ở đây thì mình dùng plugin Rank Math để tối ưu hóa link cho gọi.
1- Bỏ category trong bài viết:
Rank Math --> Link --> Strip Category Base --> Bật ON cho nó sáng lên --> Save Changes
2- Bỏ category trong SẢN PHẨM
Rank Math -->General setting--> Woocommerce --> Remove category base --> Bật ON --> Save Changes
3- Bỏ shop, product, san-pham
Rank Math --> Woocommerce --> Remove base --> Bật ON --> Save Changes
4- Thêm content vào category.
B1: Woocommerce --> thêm content vào Description.
Mã code tại đây https://www.businessbloomer.com/woocommerce-add-a-second-content-box-product-category-pages/
B2: Việc thêm này mặc định WP sẽ loại bỏ hết các thẻ heading vì vậy có 2 cách làm như sau
- Cần thêm một plugin mới có tên Allow HTML in Category Descriptions để bỏ chặn việc này.
- Tại file functions.php của theme đang dùng. Thêm đoạn code sau vào cuối.
* Allow HTML in term (category, tag) descriptions
*/
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );
if ( ! current_user_can( 'unfiltered_html' ) ) {
add_filter( $filter, 'wp_filter_post_kses' );
}
}
foreach ( array( 'term_description' ) as $filter ) {
remove_filter( $filter, 'wp_kses_data' );
}Bước 3: đến đây thì thẻ description sẽ trùng với nội dung content ta vừa paste ở bước 1. Vì vậy dùng plugin Rank Math để chỉnh sửa lại thẻ này.
Bước 4:Trang quản trị WP --> Rank Math --> Title & Meta --> Danh Mục Sản phẩm --> Add Seo Control
Bước 5: Vào Sản Phẩm --> Danh mục --> Chọn danh mục cần sửa --> Chỉnh sửa --> Hộp thoại mới Rank Math sẽ được mở, tại đây ta tùy biến title , Description theo ý muốn.
Bước 6: Đưa content này xuống chân trang
add_action( 'wp', 'tu_move_wc_archive_description' );
function tu_move_wc_archive_description() {
if ( is_archive() ) {
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_product_archive_description', 10 );
}
}
Cách 2: nếu không được thì ta chèn đoạn code sauremove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 ); add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );Chúc bạn thành công
1) Đảm bảo rằng điều hướng đến trước văn bản thứ hai.
add_action( 'woocommerce_after_shop_loop', 'bbloomer_display_wp_editor_content', 50 ); |
50 thay vì 5.
2) chỉ thêm văn bản thứ hai trên trang đầu tiên:
if ( get_query_var('product-page') == 1 && $term && ! empty( get_woocommerce_term_meta( $term->term_id, 'seconddesc', true ) ) ) { |
thêm: get_query_var ('product-page') == 1 &&
Nhận xét
Đăng nhận xét