You can use the trim
command to do this, specifically, the rtrim
to remove the character from the right side:
$url = rtrim(get_permalink(),"https://wordpress.stackexchange.com/");
Using a blanket substr -1
technique would cause problems if there isn’t a trailing slash in the permalink. Also, the function the_permalink
echoes the link, and get_permalink
returns it as a string.
Related Posts:
- Passing and retrieving query vars in wordpress
- Get the current page URL (including pagination)
- How can I reverse engineer a Permalink to Find the Page?
- Mapping Domains to Permalinks (not multisite)
- How to remove dates from existing permalinks?
- Setting up WordPress with Custom Permalinks and no .htaccess File?
- How would I create a different permalink structure for pages and posts?
- My permalinks are broken! Can I use mod_rewrite to ignore a physical file?
- When creating a WordPress page, a “-2” suffix is added to new pages’ permalinks
- mod_rewrite enabled but Permalinks show index.php
- Why does /wp-json/ not work on the “plain” permalink structure?
- Custom Permalink: /year/month/post-goes-here/?
- How to change “permalink” structure in “WordPress Thesis” theme?
- Turn off %postname% auto-incrementing?
- How to get the post id from a permalink?
- Does a parent page’s post_title have to appear in a child page permalink?
- Passing a parameter to a permalink
- Possible to use /%monthname%/ in my permalink structure without using a plugin?
- get the_title_attribute by id
- display URL or permalink instead of page title in dashboard
- How to improve WordPress security by hiding non public facing files?
- Is there a wordpress function that I can use to retrieve the current page that is loaded?
- .htaccess file missing from WordPress install directory
- CSS not loaded when omitting www. part of URL
- Is it possible to keep all special letters for foreign languages in slug as in title?
- WordPress Permalink 404
- Link to the post displays ID instead of slug
- index.php is always displayed before any file on the URL
- How do I fix permalink and media library issues on a LEMP stack?
- Include Post Format in permalink
- Non latin post slug truncate
- Why I can’t change the permalink of a WP page?
- Page preview is shown, updating page gives 404 error
- Dynamic Template file for subpage
- How to 301 redirect from one url to another properly
- How do I change the permalink of a scheduled post so that it can be linked to?
- remove product-category base but still redirect to page with same permalink
- WPML Permalink missing language slug
- What would cause a theme to add extra characters to blog post links?
- Getting 404 when Access post which name start with Digit
- Advanced author permalinks
- How to check if the current page is the permalink page?
- Format HTTP links
- Permalinks on post is working, on pages 404 error
- Change directory url to be same as page permalink?
- When do i need to get permalink structure of a specific post?
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- implement separate templates for 1 post type
- Permalinks set to /%postname%/ but still have links being indexed in the form ?p=x
- WordPress author.php template does not work with custom permalink structure! Help!
- Adding URL prefix for foreign language support
- LAMP WordPress Permalinks 404 error
- Links in post content don’t work on home page
- Arabic permalink redirect to home page
- Changing permalink settings causes 404
- Issues when changing permalink Structure
- How can I see a list of all pages my WordPress site has generated?
- Non Latin page permalink problem
- Custom permalink structure for product
- index.php in URL
- archive by year and category: permalink support doesn’t work on pagination
- Empty the_excerpt() broke the_permalink() under him?
- Permalink not changing according to post type
- iFrame permalinks on WordPress
- Change permalink structure in all sites of a multisite
- Custom permalink structure with a prefix just for posts
- Changing permalink stops me from creating webpages
- How to change permalink for listings
- WordPress Pages that use Domain URL
- 404 page not found – Yet open admin page it works
- How can I have a page’s permalink include my custom post type’s slug?
- wordpress admin panel loop on nginx
- Can’t access new WP install on subdirectory
- WordPress Permalinks
- Problem with permalinks
- Find internal links to post
- On Macbook, my permalinks with post name don’t work. Returning 404 error
- “Undefined” added to page content after google Adwords click
- create user’s view profile link with username
- WordPress pages break with custom permalink settings (theme directory not output)
- Remove /index.php from Permalink
- Image upload ruined my links
- How to rewrite a folder in WordPress?
- The Permalink doesn’t work after the foreach ended
- Permalinks setting raises 500.0 error
- Tag search not working after permalink structure change
- Why is there a # and other characters in URL for WordPress site?
- permalink repeated
- .htaccess not working in WordPress
- redirect old pages by .htaccess
- wp_get_attachment_url not working
- Custom permalink to make a page respond properly
- How to avoid duplicate Url for the home page
- WordPress 3.1 problem, getting 404
- Display a custom slug in URL depending on user variable
- htaccess strip url
- Redirect Loops Problems
- Problems loading stylesheet and permalinks after rebooting
- Add additional URL variations for a Post
- How to use ‘blogs.dir’ as media upload instead of ‘uploads’ directory in WordPress multisite setup