• Resolved rlthorman

    (@rlthorman)


    I can’t get this PHP to execute in a single post. It will execute just fine embedded on a post on the main page, but will not execute when embedded on a post and you click on that post, and see it in single post view.

    ” title=”Login”>sign in

    (I’m using plugin PHP Execution to get the PHP to execute in the HTML)

    The purpose is that users will need to login before seeing the rest of the post.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter rlthorman

    (@rlthorman)

    Sorry, forgot the backticks. Here’s the code I’m trying to execute-

    <a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">sign in</a>

    That should work unless you use one of redirection plugins (eg. Peter’s Login Redirect). I understand that you want to use it this way:

    <?php if ( is_user_logged_in() ) { ?>
    ... protected content ...
    <?php } else { ?>
    You must <a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">sign in</a> to see this post.<?php } ?>
    Thread Starter rlthorman

    (@rlthorman)

    I figured out the problem – I was trying to execute it after a More tag, which I have since learned is ignored in single.php.

    I used shortcodes instead to make things work.

    Thanks for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Execute PHP wp_login_url on single post?’ is closed to new replies.