Advertisement
mbis

Shorten product category base

Jan 21st, 2019
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. function pm_shorten_category_base($replacement, $term) {
  2.     if($term->taxonomy == 'product_cat') {
  3.         $replacement = preg_replace('/^([^\/]+)\/([^\/]+)\/(.*)/', '$1/$3', $replacement);
  4.     }
  5.     return $replacement;
  6. }
  7. add_filter('permalink_manager_filter_term_slug', 'pm_shorten_category_base', 9, 2); // Filter products permalinks
  8. add_filter('permalink_manager_filter_default_term_slug', 'pm_shorten_category_base', 9, 2); // Filter product category permalinks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement