I have a blog with two sidebars. In each sidebar there are “mini-Loops” which retrieve the title of the last post of some categories, using something like this:
$my_query = new WP_Query(SOME_PARAMETERS);
As the last widget of the last sidebar, I put Sidebar Login, but if I am viewing a single post, logging in (or logging out) redirects to the last post retrieved by the last “mini-Loop”, while it should bring me again to the same post I was viewing.
It seems that, even using a new WP_Query, $post gets updated, so when sidebar-login.php’s line 375 is executed: $pageURL = get_permalink(post->ID);
it gets the permalink of the last post retrieved by the last “mini-Loop”.
My quick fix, and my suggestion for next release, is to modify line 375 as: $pageURL = get_permalink($wp_query->post->ID);