Support » How-To and Troubleshooting » wp_loginout() active navigation state

wp_loginout() active navigation state

  • I’ve created active states for my site’s navigation which can be seen at here. It works just as I want it to. Only problem I’m having is getting an active state implemented for the wp_loginout() function. I understand there will need to be a couple different urls in the conditional statement, but can’t figure out the syntax.

    Here’s my code. Please help me out if you can. Thanks!

    <div id="menu">
    	<a href="http://eatpointshoot.com/" <?php if ( $_SERVER["REQUEST_URI"] == '/' ) echo " class='active' ";?>>recent</a>
    	<span class="space" style="margin-left:30px"></span>
    	<a href="http://eatpointshoot.com/?orderby=rand" <?php if ( $_SERVER["REQUEST_URI"] == '/?orderby=rand' ) echo " class='active' ";?>>random</a>
    	<span class="space" style="margin-left:30px"></span>
    	<?php wp_loginout()?>
    	<span class="space" style="margin-left:30px"></span>
    	<a href="http://eatpointshoot.com/default-form"<?php if ( $_SERVER["REQUEST_URI"] == '/default-form/' ) echo " class='active' ";?>>submit photos</a>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Is it single quotes?

    I’m sorry, Richard, is what single quotes? see my code above. All of the links are formatted how I want them, but I just need to figure out how to translate the “if” statement to work with the login link which uses WordPress’s wp_loginout() function.

    Thanks for looking into it!

    How about something vaguely like this?

    <?php $blah = wp_loginout( false); ?>
    (your url) <?php if ( $_SERVER["REQUEST_URI"] == '/' ) echo " class='active' ";?>


    Thanks again, Richard, but I tried this to no avail:

    <?php $userlogin = wp_loginout(); ?>
    <a href="$userlogin" <?php if ( $_SERVER["REQUEST_URI"] == '/login/') || ( $_SERVER["REQUEST_URI"] == '/login/?loggedout=true') || ( $_SERVER["REQUEST_URI"] == '/login/?action=register') echo " class='active' ";?>></a>

    I really think this is merely a php syntax issue. Any PHP wizards out there??

    I believe you have to put wp_loginout(false) – or it might be ‘false’ – to return it rather than echoing it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_loginout() active navigation state’ is closed to new replies.