DLa*_*eef 4 php wordpress woocommerce
我正在尝试修改WooCommerce产品过滤器插件,以将过滤器添加为<div class="row">代替"col-md-6".
在functions.php中,我删除了挂钩到创建函数的函数col-md-6,编写了创建rows的新函数,并添加了挂钩到我的新函数中的动作.见下面的代码.
function filter_styling()
{
echo '<div class="row">';
}
function filter_styling2()
{
echo '</div><div class="row">';
}
function product_category_filter_changes()
{
remove_action('woocommerce_before_main_content','oxy_before_breadcrumbs', 19);
remove_action('woocommerce_before_main_content', 'oxy_after_breadcrumbs', 20);
add_action('woocommerce_before_main_content', 'filter_styling', 19);
add_action('woocommerce_before_main_content', 'filter_styling2', 20);
}
add_action('init','product_category_filter_changes',10);
Run Code Online (Sandbox Code Playgroud)
添加操作正在注册,但不是注销操作.有任何想法吗?
谢谢!担
rne*_*ius 10
只有在添加了操作后才能删除操作.因此,'init'钩子可能太早了.
我建议使用'template_redirect'action hook,它将在加载插件后运行:
function product_category_filter_changes()
{
remove_action('woocommerce_before_main_content','oxy_before_breadcrumbs', 19);
remove_action('woocommerce_before_main_content', 'oxy_after_breadcrumbs', 20);
add_action('woocommerce_before_main_content', 'filter_styling', 19);
add_action('woocommerce_before_main_content', 'filter_styling2', 20);
}
add_action('template_redirect','product_category_filter_changes');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5255 次 |
| 最近记录: |