0

I have created a custom post type called portfolio so such posts have an url like this:

mydomain.com/portfolio/post-name/

This is fine so far, however i just found I am having a problem with my Wordpress login and i believe this is causing it. I have a login link on every post so if you log in from there it is supposed to redirect you back to the same post page but instead you will get a redirection loop error.

If you look at the URL which Wordpress is trying to redirect to, you will see something like

mydomain.com//post-name/  

notice how "portfolio" is missing from the URL and thats causing the redirection error.

How can i address this problem and have the redirection fixed?

Thank you.

7
  • plugin specific questions are off-topic here, you should ask the plugin author. Commented Aug 22, 2014 at 5:02
  • 1
    What plugin are you talking about?
    – Cain
    Commented Aug 22, 2014 at 5:17
  • I have no idea, but wordpress do not have a core functionality that lets you login from any page except the login page Commented Aug 22, 2014 at 6:09
  • I didnt say you can login on the page, i said i have a LINK to the login page there and thats a core functionality because if people want to post a comment they must log in first.
    – Cain
    Commented Aug 25, 2014 at 3:06
  • If you have a problem with people not being able to comment when comments are restricted to logged-in user then please edit your question and specify explicitly that that is the problem. Seriously your question has almost zero details about your site, what kind of answer do you expect to get with so little details? Commented Aug 25, 2014 at 5:47

1 Answer 1

0

How are you currently generating the login URL & handling the redirect?

You should simply be using wp_loginout and passing the permalink as the redirect, and let WordPress handle everything else:

<?php wp_loginout( get_permalink() ) ?>

Or for a more custom implementation:

<?php if ( ! is_user_logged_in() ) : ?>

    <a href="<?php echo esc_url( wp_login_url( get_permalink() ) ) ?>">My custom log in text</a>

<?php endif ?>

If you still have issues, disable all plugins. It might also be worth posting the code you use to register the custom post type.

1
  • I just found the fix for my issue. The problem is that the slug for my custom post type was in Japanese and wordpress seems unable to handle that.
    – Cain
    Commented Aug 29, 2014 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.