Maybe this doesn’t answer your question… but maybe you can adapt it to suit by changing what you put into $slug.
Try this, which should loop over posts and reset the slug to match the post name. For pages, add 'post_type' => 'page'
to the array passed to get_posts().
$posts = get_posts(array('posts_per_page' => -1));
foreach ($posts as $post) {
$slug = sanitize_title(strtolower($post->post_title));
$slug = wp_unique_post_slug($slug, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
wp_update_post(array('ID' => $post->ID, 'post_name' => $slug));
}
Related Posts:
- Why is “/page/2/” not working?
- How does WordPress handle permalinks?
- Get page permalink without wpurl
- Can I use REST-API on plain permalink format?
- How to change ‘with_front” key from an existing custom post type?
- Why would Numeric permalinks work, but %postname% won’t?
- Passing variables through permalink structure
- Make post slug have priority over category slug
- Adding anchor to paginate_links + Safari anchor bug
- How to stop permalink redirects for a particular slug
- Why does WP not use relative links when linking pages?
- What is the action or filter for changing permalink in Edit Post/Page?
- Remove Custom Taxonomy Slug from Permalink
- WordPress Links Not Working After Migration
- How to replace “wp-content/blogs.dir” with “media” for attachment permalinks?
- After moving from subdirectory to home, home page does not display
- Specific URL Rewriting with parameters in wordpress
- Can two products with the same name but different category produce unique URLs?
- If the only permalink setting is %postname% what happens in the case of old duplicates?
- Get closest page ID from URL
- How to modify the slug for the default wp posts without affecting other posttypes?
- How to create thousands of endpoints for a post or a page or a custom post type programatically?
- AWS WordPress Install – pages/posts 404 on restart until updating permalinks
- Force pretty permalinks?
- WordPress get permalink function
- Site moved to HTTPS and loads as HTTPS but permalinks show as http
- Page and Category With Same Slug – Looking To Silo Website
- Override category permalink to match old non-WordPress links?
- Exclude / Blacklist Permalinks
- Point domain to different webhost’s subdirectory wordpress
- filtering special chars from post slug
- 404 Error Problems with sCategory Permalink plugin
- Default setting permalink /blog/
- How to change old permalink?
- Need help getting my Permalink structure right
- Redirect Uploads Folder to Query Vars in WordPress
- how to link post-thumbnail to original img in a lightbox?
- Losing preview ability: W3 Total Cache + Post name permalinks
- Get the url of a page template without using the page slug and ID
- flush_rewrite_rules breaks permalinks
- How to show permalink auto when type text in post tiltle?
- Accessing Subdirectories in WordPress Install
- Permalink for custom post type
- Broken Link in WP Site?
- How to change “attachment_id” in attachment permarlink?
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- Custom permalinks in WordPress
- Permalink opens attachment instead of page
- How can I say if a URL is a post, page, or taxonomy archive?
- Changing WordPress routing to load the same page for different URLs
- Custom post type clean shortlink
- cannot link a external url, present page url acting as parent url
- add_rewrite_rule on default post type
- the_content(); erroneously closing off previous opening before it
- Bulk append URL (add word to slug)
- Image URL and size
- Conditional Permalink based on category?
- Permalink Custom Page Template
- defining child page permalink
- permalink error when modifying sanitize_title_with_dashes function
- The requested URL was not found on this server [closed]
- Shortcodes not working
- Shortlinks work only for logged in users
- Does wordpress take care of slug collisions?
- WordPress permalink not working on subdomain
- Fatal Error when trying to load Permalinks page on WP admin [closed]
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Extending page urls without getting a 404
- Permalink conflict with React Router in subfolder
- Add /blog prefix for all WordPress front end url
- Permalink structure has suddenly changed
- How to experiment with permalink structure on a select number of posts
- In a multisite, how can I get posts from one site and display their permalinks in another site?
- Why does page for hierarchical taxonomy parent term go 404?
- Custom permalink gives 404 error only in some pages
- Bulk update set of URLs via SQL
- Custom permalink for one category
- Permalink change during save of post
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- Choose permalink on a per-post basis?
- Single.php not loading when permalink only contains date information
- WooCommerce product permalink changed
- How to put articles under a /blog directory?
- Different Permastruck Between Ajax Request & Normal Request
- Imported posts using wrong domain name
- Is there a way to add slug to home_url on this function?
- Problem with multiple tags in URL
- Customized author slugs not working with get_author_posts_url method
- Custom WP permalink structure
- 404 error on second page load for child-pages
- Permalink structure as code in back-end?
- Internal Server Error every time I push up my WordPress Project to Heroku
- region selection
- Redirecting From An Old Permalink Structure
- WordPress custom permalinks, pages are now 404
- WordPress home page showing 404 error
- Include language variable in url
- Is it posible to translate a url prefix?
- Page permalinks are http but show up as https?
- Settings > Permalinks – mod_rewrite ineffective if expression not preceded by /index.php/