It’s not clear, but I’m assuming you want a ‘log out’ url, that brings the user back to the current page?
get_permalink() however, get’s the permalink of the current post in the loop (if you’re using it outside the loop, you’ll find that it takes the user to the last post in the loop after they log out).
To get the url of whatever page you’re currently on, you can use $_SERVER['REQUEST_URI']; (if there is a WordPress function that does this, apart from using add_query_arg() I would like to know it…)
So try:
wp_logout_url( $_SERVER['REQUEST_URI'] );
Related Posts:
- Pagination is not working, how to trace it properly?
- Why is “/page/2/” not working?
- Get current URL (permalink) without /page/{pagenum}/
- How does WordPress handle permalinks?
- Removing the redirect after changing a page’s slug
- 301 Redirects for Changed Permalink Structure & Category Base
- URL rewrite based on a custom field value
- How can I force WordPress to redirect to canonical permalinks?
- How do I turn off 301 redirecting posts (not canonical)?
- Subdomains to pages
- Redirect old permalinks to new permalinks
- Passing variables through permalink structure
- How can I include a query string with get_permalink
- Adding anchor to paginate_links + Safari anchor bug
- 404 on category.php pagination
- Changing pemalink structure to /%post_id%/%postname%/
- htaccess or redirect to cloak portion of a link?
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- WordPress on VirtualBox – no pretty permalinks
- WordPress 3.4 Permalinks Redirection Problem
- Random Alphanumeric Key URLs
- Redirect old permalinks with Month and name to Post name on new site
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Does WordPress send a 301 header message when you change permalink structures?
- .htaccess – Redirect duplicated post ended in ‘-number/’ to the same url without the -number/
- Top level Pages redirecting to homepage!
- WordPress redirection problem after moving to a new server?
- Specific URL Rewriting with parameters in wordpress
- Clean install – Changing permalinks in twentyeleven give 404
- Post incorrectly displaying as page
- Need Help Correct Regular Expression Redirect Code
- Infinite redirects after changing the permalink of a page
- How to Get Page 2 / Paginated RSS Feed with Custom Permalink Structure?
- Custom Permalink
- Changing the post date without causing 404 error
- Why is page/2/ not working?
- List / Get post redirects
- Redirect /%year%/%monthnum%/%day%/%postname% [closed]
- Redirect a Blogger Page URL to wordpress
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- how to redirect old blog post urls when permalinks are changed
- 301 Redirect for Non-Date Based URL’s
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- How do I make 301 redirection from `/%post_id%/` to `/%postname%/`?
- Freeze child page URLs so parent permalink changes don’t give 404s?
- Permalinks settings
- How can I make internal anchor links work with WordPress’s permalinks?
- Resolve 404 on posts without category
- What causes /pages/ to appear in URI, and how to remove it?
- How to handle paging/pagination with a custom permalink?
- Media/attachment urls don’t redirect with fake URL structure
- Test site pages go to main site
- Comment author url link is wrong? How to change from authors/ to author/
- Redirect From Url To Url
- I’ve removed my /author/ slug but it clashes with new and existing pages. Any fixes?
- After cloning WP do a subdirectory, I can’t access it
- change WordPress permalinks and redirect new urls 301
- Pagination using paginate_links
- Home page Pagination – Other pages do not redirect to home page template
- Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?
- Redirect after permalink changes
- Passing variable as permalink URL
- Blogger To WordPress Permalink Redirection
- new page redirect to old page which had the same permalink
- problem with pagination in custom permalinks
- Permalinks and page store
- All pages load the home page if pretty permalinks are used
- Change url of page according to my requirements in wordpress
- corrupted URLs – can’t leave starting page
- Find all URLs for a post
- How can i fix my permalinks?
- remove SLASH on single_post but KEEP on categories and parent pages
- Whole site’s pagination not working after rewriting product permalink
- where can i see wordpress automatic redirect History
- How to redirect old permalinks to ones generated by [WP-Hashed-ID] plugin?
- Extending page urls without getting a 404
- How to experiment with permalink structure on a select number of posts
- Disable “similar permalink” redirect [duplicate]
- redirect any category in URL to the ID and post-name only – hundreds of pages affected
- How to get a clean pagination link without variable
- Added .html to Woocommerce permalink but pagination don’t work!
- Pagination links for taxonomy archive page 404 error on every page except first
- Post redirected to page with same name but DIFFERENT permalink
- Changed Permalinks settings, how do I redirect posts on Nginx?
- Post permalinks go to the home page
- Can’t access WordPress site in subfolder possibly because of .htaccess redirect from root installation?
- changing permalink gives 404 error for old links
- How to hide slug numbers with htaccess
- Add Custom Pagination Permalink
- All pages lead to home
- Redirect Pretty Permalinks to Ugly Permalinks
- WordPress permalink still not working (error or not understood?)
- Category pagination first link works, remaining don’t
- My wordpress site must be being affected by outside sources [duplicate]
- Redirecting From An Old Permalink Structure
- Getting the terms from “Beautiful Taxonomy Filters” Results ot Integrate into “Ajax Load More”
- Post archive pages bringing me to a 404 page
- 404 posts error after 301 redirection of changed category / tag base
- Changing the URL slug causes redirecting to homepage, or showing 404 or missing lang_code issue