admin管理员组文章数量:1122846
When filtering the permalink structure it looks like this:
https://constructions-equipments/shop/swoof/brand-caterpillar/
But it should show like:
https://constructions-equipments/shop/?swoof=1&pa_application=caterpillar
When filtering the permalink structure it looks like this:
https://constructions-equipments/shop/swoof/brand-caterpillar/
But it should show like:
https://constructions-equipments/shop/?swoof=1&pa_application=caterpillar
Share
Improve this question
edited Apr 2, 2024 at 0:48
Tony Djukic
2,2594 gold badges18 silver badges33 bronze badges
asked Apr 1, 2024 at 13:39
LM10LM10
12 bronze badges
1
- Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Apr 2, 2024 at 0:48
1 Answer
Reset to default 0You want to change the URL structure from something like /shop/swoof/brand-caterpillar/ to /shop/?swoof=1&pa_application=caterpillar
so you can use wp built in rewrite rules and query parameters. You will need to add custom rewrite rules and handle query parameters accordingly.
add custom rewrite rules to map the desired URL structure to the appropriate query parameters.
Add code in your currently active theme of the functions.php
file
1.Add Custom Rewrite Rules
function custom_rewrite_rules() {
add_rewrite_rule('^shop/swoof/brand-([^/]+)/?', 'index.php?post_type=product&swoof=1&pa_application=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_rules');
This rule will rewrite URLs like /shop/swoof/brand-caterpillar/
to /index.php?post_type=product&swoof=1&pa_application=caterpillar
2.After adding custom rewrite rules, you need to flush the rewrite rules so that Wordpress can recognize them.
Go wp admin area to change the permalink structure Settings > Permalinks
and simply click the "Save Changes" button.
URL structure is rewritten, you need to handle the query parameters in your theme or plugin to filter the products accordingly.
you can use WooCommerce hooks or custom query modifications to adjust the product query based on the swoof
and pa_application
parameters
本文标签: pluginsSwoof filter settings
版权声明:本文标题:plugins - Swoof filter settings 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736312050a1934961.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论