On Github mboynes / wcnyc-2015-rewrite-testing
Matthew Boynes / @senyob / alleyinteractive.com
What are they?
Rewrite rules are WordPress' system for managing "pretty permalinks". It's regex-based. Who here loves regular expressions? Hate them? Anyway.../foo/bar/ ↓index.php?post_type=foo&name=bar
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
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' );
Are you a good developer who wants to be a great developer?We're hiring.
hiring@alleyinteractive.com