Matthew Boynes / @senyob / alleyinteractive.com
What are they?
/foo/bar/
↓
index.php?post_type=foo&name=bar
add_rewrite_rule()
add_rewrite_endpoint()
add_permastruct()
%my-taxonomy%
%my-taxonomy%
([^/]+)
my-taxonomy=$matches[n]
[url]/print/
array(
regex => query string,
regex => query string,
...,
)
'tag/([^/]+)/?$'
=>
'index.php?tag=$matches[1]'
Amongst others...
https://wordpress.org/plugins/rewrite-testing/
https://github.com/alleyinteractive/rewrite-testing/
Let's say we're building a recipe site
%primary-ingredient%
/%primary-ingredient%
/%recipe%
/Filter: rewrite_testing_tests
Filters an array of test groups
Test URL => Passing match
'/recipes/' => 'index.php?post_type=recipe'
function wcnyc_rewrite_tests( $tests ) {
$tests['Recipes'] = array(
'/recipes/' => 'index.php?post_type=recipe',
'/recipes/eggplant/' => 'index.php?post_type=recipe&primary-ingredient=$matches[1]',
'/recipes/eggplant/eggplant-parmesan/' => 'index.php?primary-ingredient=$matches[1]&recipe=$matches[2]&page=$matches[3]',
);
return $tests;
}
add_filter( 'rewrite_testing_tests', 'wcnyc_rewrite_tests' );
exit();
Are you a good developer who wants to be a great developer?
We're hiring.
hiring@alleyinteractive.com