Support

Content of the article

You need to log-in to create request (topic) to the support

init_only_on

(new from 01-07-2019)

Hi,

I have the WOOF filter set up on my site and it is working well. I would like to limit the filter to only appear on certain category pages. I currently have a function that displays a header and calls the short code and hooks into the product category archive pages. I can limit the function to only appear on certain pages using "if (is_product_category ('heritage'))" but I would like to use the "Init plugin on the next site pages only" function to control this so my customer can easily change which pages it displays on. Can you suggest how I can pick up the init_only_on settings in my function to do this. The function is:

function display_city_filter() {
if ("some method to detect if the category is included in the setttings page") {
echo '<h3>Product Filters</h3>';
echo do_shortcode("[woof sid ='flat_grey woof_auto_3_columns']"); }
}
add_action('woocommerce_before_shop_loop', 'display_city_filter', 15);

 

Thanks

Hello

Try  to use:

function display_city_filter() {
if ( shortcode_exists( 'woof' )) {
echo '<h3>Product Filters</h3>';
echo do_shortcode("[woof sid ='flat_grey woof_auto_3_columns']"); }
}
add_action('woocommerce_before_shop_loop', 'display_city_filter', 15);

Thanks - that worked perfectly!

Hello

 

Welcome;)