Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove Stop Words from URL
* Remove Stop Words from URL By
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) {
return implode('-', $slug);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment