Title: Weird get_permalink() problem
Last modified: August 19, 2016

---

# Weird get_permalink() problem

 *  [fonix232](https://wordpress.org/support/users/fonix232/)
 * (@fonix232)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/weird-get_permalink-problem/)
 * I was just redoing my old personal login widget, and found this nice way of creating
   a logout url:
 * `<?php echo wp_logout_url(get_permalink()) ?>`
 * But there is a problem with this. Any time I click the URL generated by this 
   code, it redirects me to
 * ` bloginfo(‘url’)/?p=1 ‘
 * no matter where I am.
 * I want my users to get back the page they were looking at when they click this
   link, but also I want to keep this nice new and clean way!
 * Is it possible?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Edward Caissie](https://wordpress.org/support/users/cais/)
 * (@cais)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/weird-get_permalink-problem/#post-1509875)
 * `get_permalink()` must be used in the loop … is your login widget part of the
   loop?
 * PS: I tested this with my BNS Login plugin and it gives a similar “error” to 
   what you are describing if I change the code to your example.
 *  Thread Starter [fonix232](https://wordpress.org/support/users/fonix232/)
 * (@fonix232)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/weird-get_permalink-problem/#post-1509879)
 * Well, my plugin has no the loop inside it, so it can not be in the loop.
    Any
   suggestions how to add the loop to the plugin, without displaying any other things?
   I’m not a too big WordPress developer sadly.
 *  [Edward Caissie](https://wordpress.org/support/users/cais/)
 * (@cais)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/weird-get_permalink-problem/#post-1509881)
 * If this is just for your personal use with your current theme, I would suggest
   some possible (untested) ideas:
    1. Add a variable into the loop used in single.php, page.php, etc. to capture the
       permalink, such as `$static_link = the_permalink()`
    2. Edit your “widget” to return the blog URL if on the home or front page, else
       use the $static_link as the redirect URL

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Weird get_permalink() problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Edward Caissie](https://wordpress.org/support/users/cais/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/weird-get_permalink-problem/#post-1509881)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
