Here is your code:
if ( isset($_GET['slug-update']) ) {
$posts = get_posts();
foreach($posts as $singlepost) {
if($singlepost->post_status === 'publish'){
$post_id = $singlepost->ID;
$current_slug = $singlepost->post_name;
$updated_slug = $current_slug . '-word';
}
wp_update_post( array(
'ID' => $post_id,
'post_name' => $updated_slug ) );
}
die('Slug Updated');
}
Add this to your theme’s function.php. Then run this with www.example.com/?slug-update
P.S. this will only update the default post type ‘post’ (backup the database to be secure)
Let me know if this helped.
Related Posts:
- remove “index.php” from permalinks
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Getting the Site URL Including the Front Base
- How to prevent apostrophes and quotes from appearing in permalinks?
- Update URL Snippet to Canonical Permalink URL
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Pretty Permalinks
- Remove parent slug for child pages
- How to create a permalink structure for posts in a specific category
- How to Remove Slug From Database?
- How to make draft posts or posts in review accessible via full url / slug?
- Remove subfolders from URL
- Remove parent slug for child pages
- Limiting the number of words or characters in the slug/permalink
- flexible rewrite ‘ramble’ URLs with WordPress
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- Make attachment pages require a base url
- How to Modify Existing Rewrite Rules?
- custom permalink/shortlink with base62 encoded post ID
- Change author slug and functionality
- How to reset canonical URLs / fix redirect loop
- How can I add a page’s ID to its permalink using WP_Rewrite?
- Change blog segment of URL
- Non latin post slug truncate
- Force wordpress to display page with same url structure as categories
- Share same Slug for a Custom Post Type and 2 Taxonomies
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- Pre-populate Slug / Permalink with URL
- mod-rewrite exception? keep #hash in matching urls?
- wordpress how to replace url /bar with foo/bar for custom post type
- Remove parent page from url
- Suddenly new posts have the default permalink instead of the post name
- Getting back a permalink from custom url
- add_rewrite_rule – Page Slug from “/foo-bar/” to “/foo/bar/”
- Access posts while mod_rewrite is broken
- Remove international characters from slug – Almost done – Bit help
- Can I change the URL structure for a CPT only?
- How to remove slug from front page?
- How do I structure my permalinks in WordPress?
- A different permalink structure for different categories
- assets aren’t loading on a page but loads on others? slug permalink conflict?
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Using a template file for a specific custom URL
- Extra url paths as variable
- Passing parameter through permalink structure
- How to create a standard WP Page that has the same url as an archive
- rebuilding/ rewriting a url to make it SEO friendly
- a way to support totally different url structure
- How to change URL of my pages?
- Custom Permalink Base
- Include language variable in url
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- Get Page URl when changing slug and permalink
- Can’t Remove Unnecessary Slug
- How to use relative links on my pages?
- Change slug on post creation
- WordPress Permalink changes to question mark (?) in URL
- How to prevent the default home rewrite to a static page
- WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel
- Handle category name URL rewrite before different post type slugs
- How to get url of a post from admin panel
- Exclude subcategories from the url
- Rewrite user profile URL to be human friendly
- rewrite_rule for custom post type doesn’t affect get_permalink
- Add ‘articles’ prefix before blog posts url without affecting pagination
- Call to a member function add_rule() on a non-object
- Does rename of page slugs create 301 redirects from old slug to new (same as for posts)?
- How to stop WordPress from removing & from URL?
- How to bulk edit image url in featured image and product description?
- Preserve old website URL structure after migrating to WordPress
- Redirect a Blogger Page URL to wordpress
- Edit page slug after save, cause 404 by linked pages
- Create custom permalinks to show Custom Post Type’s relationship?
- IIS 7 Rewrite with parent categories
- Permalinks settings
- Gutenberg Editor: dynamically edit slug field based on ACF field
- Permalinks (don’t kill me) refuses to work..Yes, it results in a 404
- 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
- WP permalink working, but why content doesn’t display
- Redirect page to homepage, keeping URL
- Adding query string to multiple page urls in a WordPress function
- I have Akamai pointing to a WordPress installation with a different URL. Is there a way to make WordPress use this for link generation?
- How can I put WordPress in a directory but keep just the home page at the domain root?
- How to allow different authors to use same post slug?
- Updates all internal links on permalink update
- how to have same rewrite rules for 2 different post type?
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Is there a way to remove the option to modify the Slug in post.php
- Issues with WordPress permalinks
- Update permalinks after domain change
- How to shorten the Permalink after WP>WP blog import?
- After I migrated a website for WordPress – Saved changes in wordpress settings >> permalinks. Homepage only working, links not working
- UI does not show correct Slug after modified using save_post action
- Blog URL Structure – Multiple Taxonomies