Code chuyển phần mô tả của danh mục sản phẩm xuống dưới cùng phần sản phẩm
[wpsm_codebox style=”2″]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 );
}
}[/wpsm_codebox]
Cách Thêm đuôi .html vào link sản phẩm woocommerce WordPress
[wpsm_codebox style=”2″]/** Customize link woo anbiweb*/
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’ );
}
Related articles: