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?
- How does WordPress handle permalinks?
- How can I force WordPress to redirect to canonical permalinks?
- Make post slug have priority over category slug
- Is using %postname% for permalinks really that bad for performance?
- Setting up two separate blogs while using WordPress as a CMS
- Use Regular Expression to get tag from permalink url during wp_rewrite in generate_rewrite_rules
- How to redirect to correct pages after permalink structure change
- Is there a link parameter that will show me all my published pages?
- Add prefix to page URL based on the page template
- How to remove specific category from URL in WordPress
- Custom permalink leads to index page
- wp not making CPT permalink / slugs unique
- WordPress keeps giving me the wrong permalink
- Permalinks 404 error with HTTPS host
- Mirror content based on URL slug
- How to change hierarchical page permalinks to be flat
- Relative v.s. absolute URLs: which ones should I use for cross-domain portability?
- How Do I get the author’s page id?
- How do I add a tag slug to a category URL to filter posts?
- Order custom post type posts by custom field with pretty URL
- Show category name in the post URL only for specific categories
- how do prevent wordpress from creating permalinks for media files
- How are WordPress Page URLs affected by permalink settings?
- How to create posts or pages with the names in wordpress?
- replicate url permalink after migrating to wordpress
- Modify post slug before saving
- Does wordpress take care of slug collisions?
- Make the blog page a child of another page and rewrite the blog url
- WordPress slug confusion
- append current user-id to all internal permalinks
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- Two CPT: one is using part of the custom rewrite slug from the other
- Pagination links for taxonomy archive page 404 error on every page except first
- Change all pages permalinks instead of hierarchical to have id of the page
- Category-dependent custom permalink
- Imported posts using wrong domain name
- Customized author slugs not working with get_author_posts_url method
- ?posts_type=xxx not rewritten
- region selection
- WordPress custom permalinks, pages are now 404
- Add additional URL variations for a Post
- Remove parent product category slug from product_cat url woocommerce
- How to make my custom permalink pull up the correct post