You don’t need to use any code for this. You just need to:
- Go to your /wp-admin/options-permalink.php page
- Select the ‘Custom Structure’ and enter:
/%postname%/%post_id%/
- Then press the ‘Save’ button
Related Posts:
- Is it possible to get a page link from its slug?
- Remove parent slug for child pages
- How to Remove Slug From Database?
- Remove parent slug for child pages
- Change author slug and functionality
- Share same Slug for a Custom Post Type and 2 Taxonomies
- Add prefix to page URL based on the page template
- get_permalink returning site home url instead of the url of slug being passed
- Passing the JQuery string to Worldpress URL
- wordpress how to replace url /bar with foo/bar for custom post type
- Bulk append URL (add word to slug)
- add_rewrite_rule – Page Slug from “/foo-bar/” to “/foo/bar/”
- How are WordPress Page URLs affected by permalink settings?
- Page content doesn’t display when published but does when previewed as draft?
- Subdomains pointing to a permalink URL
- How do I structure my permalinks in WordPress?
- Change all pages permalinks instead of hierarchical to have id of the page
- How does WordPress handle permalinks?
- Creating custom permalink structure for languages
- How to add a custom URL placeholder to author archives?
- How can I force WordPress to redirect to canonical permalinks?
- Passing variables through permalink structure
- permastruct for custom post type not working in one of four cases
- Make post slug have priority over category slug
- Remove subfolders from URL
- flexible rewrite ‘ramble’ URLs with WordPress
- Change the custom post type permalink
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Relative or Absolute Paths for Flash Video Player Files
- How to Modify Existing Rewrite Rules?
- Is using %postname% for permalinks really that bad for performance?
- Rewrite Page with a slug before page name
- Page Attachment Permalink Structure based on Menu Order?
- 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?
- Permalinks: Page Not Found
- Permalinks by page/post name returning 404
- remove sub-category of Custom Post Type from permalink structure
- WordPress Permalinks & Nginx Rewrite Rule Not Working
- Is a permastruct possible on pages?
- filtering special chars from post slug
- How to add a variable as a tag base?
- WPML – how to get the permalinks to display also the default language
- force permalink slug for page vs post_type slug parent
- Need to add trailing slash to all internal links relative and absolute
- Get the url of a page template without using the page slug and ID
- Multiple URL’s based on category for one post
- Let me choose permalinks
- How to rewrite a URL to another rewritten URL without changing the address?
- Custom permalinks in WordPress
- Permalink opens attachment instead of page
- How can I emulate permalink behaviour on static pages
- cannot link a external url, present page url acting as parent url
- Test site pages go to main site
- Getting back a permalink from custom url
- how to get a list of all top level pages
- Permalinks on Windows IIS not working and web.config breaks site – does wordpress not support windows server now, if so how?
- I’ve removed my /author/ slug but it clashes with new and existing pages. Any fixes?
- Exclude single page from permalink rule
- Rewrite rule not passing variable
- Access posts while mod_rewrite is broken
- Update page breaks permalinks
- How to create posts or pages with the names in wordpress?
- How to remove slug from front page?
- 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
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- How can I access to the same post-type “page” from multiple different urls?
- Using a template file for a specific custom URL
- Add word to permalinks does not transform the urls
- permalink not showing correctly using wp_insert_post and post_name
- 404 error on published page with specific permalink
- Can I link to content dynamically from a page to a new page?
- How to make “single post” permalink maintain it’s sub-page structure
- append current user-id to all internal permalinks
- rebuilding/ rewriting a url to make it SEO friendly
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- My permalinks for all pages and posts now include old page titles as parents/categories
- Two CPT: one is using part of the custom rewrite slug from the other
- Page returns 404 for specific permalink
- Pagination links for taxonomy archive page 404 error on every page except first
- WordPress Pagination Custom Rewrite Rule for Pages
- How can I get .html URL suffixes in permalinks?
- Category-dependent custom permalink
- Change the permalinks structure
- All pages lead to home
- Customized author slugs not working with get_author_posts_url method
- Remove index.php from WP 8.0 install migrated to IIS from Apache (still detecting Apache server)?
- ?posts_type=xxx not rewritten
- Category pagination first link works, remaining don’t
- region selection
- WordPress custom permalinks, pages are now 404
- Why doesn’t my page know it’s a page (won’t return true for is_page())?
- Include language variable in url
- Add additional URL variations for a Post
- Blog posts are not appearing as subs of Blog Page
- How to make my custom permalink pull up the correct post