Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created June 27, 2017 14:54
Show Gist options
  • Save djrmom/f38a626cfb6fdc51e6b0c4e07c1e347a to your computer and use it in GitHub Desktop.
Save djrmom/f38a626cfb6fdc51e6b0c4e07c1e347a to your computer and use it in GitHub Desktop.
wordpress rewrites
<?php
/**
* remove search rules so that we can use /search/slug/ as a page
*
* @param $rules
*
* @return mixed
*/
function prefix_links_remove_search($rules){
foreach ($rules as $rule => $rewrite) {
if ( preg_match('/^search/',$rule) ) {
unset($rules[$rule]);
}
}
return $rules;
}
add_filter('rewrite_rules_array', 'prefix_links_remove_search');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment