学习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;
}