R
R
RomanGorkunenko2018-10-16 11:00:35
WordPress
RomanGorkunenko, 2018-10-16 11:00:35

How to change the url in the Wookomers widget for filtering products by attributes?

Hello. Tell me, please, in Wookomers there is a widget for filtering goods by attributes class-wc-widget-layered-nav in the url it turns out ../shop/?filter_color=red, I want to do ../shop/color/red . Found and removed 'filter_' link is already displayed without 'filter_'. As I understand it, further in this line you need to dig $link = add_query_arg( $filter_name, implode( ',', $current_filter ), $link ); but what I'm not doing here is displayed as I need, but does not work. What else needs to be changed? before that I tried using add_rewrite_rule, but something doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RomanGorkunenko, 2018-10-16
@RomanGorkunenko

Here is the code used for add_rewrite_rule:

add_action('init', 'do_rewrite');
function do_rewrite(){
  add_rewrite_rule( '^color/([^/]*)/?', 'shop?color=$matches[1]', 'top' );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question