There should be no problem with unset
. There is your answer. What matters with a filter is what you return and unset
ing those keys before your rebuild the string and return it, works.
You are doing too much processing by explode
ing your $keys_false
inside a loop, and you have a typo, and you are better off just making an array instead of creating a string that you convert to an array, and PHP has a function to do what your loop is doing. I reorganized it for you.
function remove_false_words($slug) {
if (!is_admin()) return $slug;
$keys_false = array('a','and','above','the','also');
$slug = explode ('-', $slug);
$slug = array_diff($slug,$keys_false);
return implode ('-', $slug);
}
var_dump(remove_false_words('a-boy-and-his-dog')); // proof of concept
Related Posts:
- how to get page id of a page using page slug
- Get page content using slug
- Is there a maximum slug length?
- How to check if a slug exists?
- Can I use a number for a post/page slug?
- Force post slug to be auto generated from title on save
- How to rewrite slug of custom post type archive page
- How to get full slug, including all parent pages
- Add warning to edit slug/permalink button on editor screen.
- Change slug with custom field
- How to generate slugs?
- Can we have a php “page” without a WordPress “page”?
- {Check Theme Plugin} text domain does not match the theme’s slug
- Possible to create a new post and have the Title and Slug automatically use the post’s ID?
- Display page over category archive
- Convert post name into post ID
- WP appending -2 to the end of my slug. Where are the originals stored so I can delete them?
- Function to list all post slugs for every post in my WP database?
- Add parent template name to body class filter when visiting subpage or single post
- How I Can Use The Get Value as A Slug
- Set taxonomy slug as taxonomy title
- custom slug always ends in “-2”
- Put a link to a category round a hard coded A HREF
- Get ID of child from child slug, while knowing parent ID
- Show all wp_get_post_terms slugs
- How can I automatically set a post slug based on the post title during post publish?
- Get posts with at least one category in common with current post?
- slug: should I use latin characters only?
- How to manage same slug posts suffix method?
- Make wp_list_pages print slugs instead of titles
- Stripping unicode characters out of slug
- WordPress custom slug (endpoint) and compare all links
- Global variable $post returning incorrect object
- How do you use WP slugs for PDF files / media?
- Remove slugs of old and unused custom post type
- What function removes apostrophes when making a slug?
- WordPress not adding -2 to slugs when saving post as draft
- WordPress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs
- What is an equivalent of single_cat_title for getting the slug of the category?
- What query string parameter is available for index.php, that works for both pages and blog articles?
- php script to change slug in post automatically
- Memberpress custom fields – filtering content
- Duplicate category slugs from pages and posts
- How to show “slug” in admin column?
- Change post slug but keep old one
- Why does post-slug not get saved for drafts?
- Remove custom post slug and add category to custom post type
- Redirect to another page using contact form 7? [closed]
- List taxonomy term slugs within shortcode (do_shortcode)
- Slug Taken, Cant Find Which Page
- How to get a page slug in WordPress?
- A way to export slug as meta tag
- Adding language based URL structure
- Remove slugs from custom posts type
- Display Terms Comma separated and Hyperlinked
- Is it possible to create slug on homepage and how?
- what to do when a Theme uses a custom post type slug that conflicts with a plugin?
- Wrong slug on blog page
- Getting the slug into a variable, how to echo that variable
- Set a custom post type’s title and slug to match the current date
- add slug of child(ren) to li using wp_list_pages
- Category Slugs = 404s?
- How to prevent post_name from incrementing in wp_insert_post?
- How can I get wordpress slug without certain phrase? [closed]
- Allow two posts (from different categories) to have the same slug
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Get nice name of category from slug (remove dashes of category)
- Custom PHP form needs refresh to load page correctly
- Check for the existence of term slug
- Show code dependant on CPT & category
- Slug duplicates once clicking on link
- Rewrite rule not working, but only when parameter is text
- How to ignore GET parameter that’s the same as a CPT slug?
- Hide a specific category title from displaying on site
- Make user’s first and last name as user slug
- Default post category overruling %category% setting for posts URL
- 404 errors problem with multilangual permalink pages
- How can I output the slug of a comment author?
- Show post by slug sanitize_title
- Category Name and Slug field need to be the same otherwise it breaks category pages
- WordPress using get_term to retreive slug not working as expected
- Get all terms/slugs – used, not used & in hierarchical order
- Bulk-change Post slugs which have a suffix
- Weird slug in archives permalink
- php string inside shortcode does not work
- How to Disable UNICODE slug?
- get_category only returning details for ‘uncategorized’
- list child pages as slug
- can’t change page slug
- Echo author slug in post edit page
- How to put title slug into content when create a new post?
- WordPress v3.1 Has Character Encoding Issue With Title/Permalink?
- Ultimate get current page’s slug function
- How can I make “sanitize_title” affect only one taxonomy?
- How to create extra SUB ARCHIVE for each page?
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- Remove /Page/ from slug when we’re visiting 2nd and other inner pages of the blog page
- Create a custom plugin with dynamic child pages listing database records
- Slug is already taken – how do I find the original item
- Duplicate Slugs on multilingual site (with Polylang)