Thêm đuôi .html vào link sản phẩm woocommerce WordPress

5/5 - (1 bình chọn)

biweb hướng dẫn cách đơn giản nhất để Thêm đuôi .html vào link sản phẩm woocommerce WordPress.

Hãy chèn đoạn code dưới dây vào file functions.php trong theme wordpress bán hàng . Sau khi thêm xong hãy vào bên trong admin cấu hình lại đường dẫn và nhớ bấm Lưu thiết lập

/** Customize link woo Zubi Cloud*/

add_action('init', 'it60s_change_page_permalink', -1);
function it60s_change_page_permalink() {
global $wp_rewrite;
if ( strstr($wp_rewrite->get_page_permastruct(), '.html') != '.html' )
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}

add_action( 'rewrite_rules_array', 'rewrite_rules' );
function rewrite_rules( $rules ) {
$new_rules = array();
foreach ( get_post_types() as $t )
$new_rules[ $t . '/([^/]+).html$' ] = 'index.php?post_type=' . $t . '&name=$matches[1]';
return $new_rules + $rules;
}

add_filter( 'post_type_link', 'custom_post_permalink' ); // for cpt post_type_link (rather than post_link)
function custom_post_permalink ( $post_link ) {
global $post;
$type = get_post_type( $post->ID );
return home_url( $type . '/' . $post->post_name . '.html' );
}
5/5 - (1 bình chọn)


Trả lời