woof_template_part
在短代码中动态更改模板 [woof_products]
自 v.1.1.8/2.1.8
参数
$template (string) — the template name ('product' by default)
源文件
index.php
代码示例
add_filter('woof_template_part', function($template) {
// Use a custom template for products display
// Place your template at: wp-content/themes/your-theme/woof/product-custom.php
$custom_template = 'product-custom';
if (is_product_category('specials')) {
return $custom_template;
}
return $template;
});
使用说明
- 将此代码添加到您主题的
functions.php文件或自定义插件中。 - 钩子在筛选过程中应用——更改立即生效。
- 始终从回调函数返回预期的值类型。
