jenny-r
6/27/2017 - 2:54 PM

wordpress rewrites

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');