學習storefront模板發現,整個模板基於wordpress的插件機制,通過動作(do_action、add_action、remove_action)定義模板各個模塊的順序和位置。和woocommerce的機制一致。和學習的另一個模板tyche完全不一樣,tyche模板是通過sidebar、widgets定義整個模板的順序和位置。
在子模板function.php中加入定製函數
function remove_storefront_action(){
//storefront-template-hooks.php中:
// remove_action( 'storefront_header','storefront_product_search',40);
remove_action( 'storefront_header','storefront_header_cart',60);remove_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
// remove_action( 'storefront_header','storefront_primary_navigation_wrapper ',42);
// remove_action( 'storefront_header','storefront_primary_navigation',50);
// remove_action( 'storefront_header','storefront_primary_navigation_wrapper_close',68);
remove_action( 'storefront_content_top', 'storefront_shop_messages', 15 );
remove_action( 'storefront_footer', 'storefront_credit', 20 );
remove_action( 'storefront_homepage', 'storefront_homepage_header', 10 ); //顯示標題
remove_action( 'storefront_page', 'storefront_page_header', 10 ); //顯示標題
remove_action( 'homepage', 'storefront_product_categories', 20 ); //homepage 主頁顯示
remove_action( 'homepage', 'storefront_homepage_content', 10 ); //主頁顯示
// remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
remove_action( 'storefront_after_footer', 'storefront_sticky_single_add_to_cart', 999 );
remove_action( 'woocommerce_after_single_product_summary', 'storefront_single_product_pagination', 30 );
//woocommerce插件中: woocommerce/includes/wc-template-hooks.php
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); // woocommerce onsale
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 ); //onsale
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6 ); //storefront onsale
}
add_action('init','remove_storefront_action');
在模板的Customize中加入css的目的是麪包導航和內容之間空間太大,這樣減少空間
.storefront-breadcrumb{
margin-bottom:5px;
}