1) Add this rewrite at the end of you function.php
function add_rewrite_rules( $wp_rewrite )
{
$new_rules = array(
'YOUR_PREFIX/(.+?)/?$' => 'index.php?post_type=post&name=". $wp_rewrite->preg_index(1),
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action("generate_rewrite_rules', 'add_rewrite_rules');
function change_blog_links($post_link, $id=0){
$post = get_post($id);
if( is_object($post) && $post->post_type == 'post'){
return home_url('/YOUR_PREFIX/'. $post->post_name."https://wordpress.stackexchange.com/");
}
return $post_link;
}
add_filter('post_link', 'change_blog_links', 1, 3);
2) Go to Settings > Permalinks and click Save Changes
.
Related Posts:
- Prevent WordPress from abbreviating-long-slugs…-in-the-admin
- Permalinks Question: Adding a prefix ONLY in front of the posts
- Permalinks not working (.htaccess is writable)
- How can I link a file in admin with a button?
- Change Buddypress Admin Profile Page Permalink
- Logging in to installation in subdirectory renders broken dashboard (no CSS, broken links)
- Mystery ghost page not appearing in Admin
- AllowOveride All causes assetts and Admin Urls to 404
- 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?
- Post titles not letting me use 2 consecutive dashes in permalink
- 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?
- Posts not working on windows after changing permalinks
- Remove Custom Taxonomy Slug from Permalink
- WordPress Links Not Working After Migration
- Migrating WordPress blog to New Webhosts, something is adding a # and gibberish
- Adding File Extensions to Attachment Page Permalinks
- How to tranform Headlines into linkable permalinks?
- Best way to add internal link in widget
- Changing search URL to something other than “search”
- article pages not displaying on local instance of wordpress site
- breadcrumbs & rel=”nofollow”
- Use Regular Expression to get tag from permalink url during wp_rewrite in generate_rewrite_rules
- Permalinks for pages
- Create unique alphanumeric ID on wp_insert_post
- Programatically changing post’s permalink when identical post type is published
- Permalinks not working with Vagrant
- Possible to remove taxonomy from permalink if uncategorized?
- Is there a link parameter that will show me all my published pages?
- Add prefix to page URL based on the page template
- Files rendering adding “.x95527” before file extension [closed]
- Permalink /%postname%/ doesn’t work
- How to change hierarchical page permalinks to be flat
- Permalink structure with $_SESSION variables
- Relative v.s. absolute URLs: which ones should I use for cross-domain portability?
- Strange Anchor Tag Behavior (in-page links work, external pages do not) [closed]
- WordPress 3.1 .htaccess contents keep dissappearing?
- Permalink in WordPress loop outputs for each new line
- Freeze child page URLs so parent permalink changes don’t give 404s?
- New custom PHP pages are getting 404s
- What causes /pages/ to appear in URI, and how to remove it?
- Add a filter to get_comments_link()
- How Do I get the author’s page id?
- WordPress Installed But Not Showing Up! [closed]
- Importer failed to import posts as format “day and name”
- Adding a prefix to the blog, but only the blog
- Old site posts broken after domain update
- After cloning WP do a subdirectory, I can’t access it
- Moved site, Old links in pages still pointing to old host
- help to remove last trailing slash using add_rewrite_rule
- change WordPress permalinks and redirect new urls 301
- Protect Post Permalink From Copy
- WordPress Page Not Found if Permalink Settings is Postname
- WordPress Permalink Redirect 301
- problem with pagination in custom permalinks
- Problems with permalinks (.htaccess not working)
- Change author permalink using htaccess?
- /%post_name%/ or /%postname%/ in Permalinks?
- Remove international characters from slug – Almost done – Bit help
- flush_rewrite_rules on MultiSite
- WordPress permalink not working on subdomain
- 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
- Can I link to content dynamically from a page to a new page?
- Custom permalink for one category
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- Remove index.php from URL (WP installed in subdirectory)
- Choose permalink on a per-post basis?
- Single.php not loading when permalink only contains date information
- WooCommerce product permalink changed
- 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?
- Remove parent product category slug from product_cat url woocommerce