Skip to content

Instantly share code, notes, and snippets.

@WPDevHQ
Created May 17, 2016 17:44
Show Gist options
  • Save WPDevHQ/e735b3034f5ea8fc41ce700e1065d657 to your computer and use it in GitHub Desktop.
Save WPDevHQ/e735b3034f5ea8fc41ce700e1065d657 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'rewrite_rules_array', function( $rules ) {
$new_rules = array(
'shop/([^/]*?)/page/([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&paged=$matches[2]',
'shop/([^/]*?)/?$' => 'index.php?product_cat=$matches[1]',
);
return $new_rules + $rules;
} );
@WPDevHQ
Copy link
Author

WPDevHQ commented May 17, 2016

Add the above rewrite rules to either the child theme's functions.php or better still, use a site functions plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment