Skip to content

Instantly share code, notes, and snippets.

@shemul49rmc
Created December 13, 2013 09:48
Show Gist options
  • Save shemul49rmc/7942098 to your computer and use it in GitHub Desktop.
Save shemul49rmc/7942098 to your computer and use it in GitHub Desktop.
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