• 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)
  • 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

    (@fonix232)

    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.

    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.