Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove Stop Words from URL
/**
* Remove Stop Words from URL By http://goo.gl/ht6fZo//
*/
add_filter('sanitize_title', 'remove_stop_words');
function remove_stop_words($slug) {
if (!is_admin()) return $slug;
$slug = explode('-', $slug);
foreach ($slug as $k => $word) {
// List of stop words comma separated
$keys_false = 'a,the,him,her,how';
$keys = explode(',', $keys_false);
foreach ($keys as $l => $wordfalse) {
if ($word==$wordfalse) {
unset($slug[$k]);
}
}
}
return implode('-', $slug);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment