jiverson79
Member
Posted 11 months ago #
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>
</div>
richarduk
Member
Posted 11 months ago #
jiverson79
Member
Posted 11 months ago #
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!
richarduk
Member
Posted 11 months ago #
How about something vaguely like this?
<?php $blah = wp_loginout( false); ?>
(your url) <?php if ( $_SERVER["REQUEST_URI"] == '/' ) echo " class='active' ";?>
http://codex.wordpress.org/Function_Reference/wp_loginout
jiverson79
Member
Posted 11 months ago #
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??
richarduk
Member
Posted 11 months ago #
I believe you have to put wp_loginout(false) - or it might be 'false' - to return it rather than echoing it.