I have a problem. My site is one page template and its looking nice. I have added navwalker and it looks nice and working dynamically. But the problem is in my now I have added login and logout modal button and its have modal trigger and PHP code also. Now question is How can I login, logout using in navwalker?

Static Code:

<div id="navbar" class="navbar-collapse collapse">
    <ul id="top-menu" class="nav navbar-nav navbar-right main_nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#service">Services</a></li>
        <li><a href="#contact">Contact Us</a></li>
        <li><a href="" data-toggle="modal" data-target="#1myModal">Join Now</a></li>
        <?php
        if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        ?>
        <li><a href="<?php echo wp_logout_url( home_url() ); ?>">Log out</a></li>
        <?php
        } else {
            ?>
        <li><a href="" data-toggle="modal" data-target="#2myModal">Log In</a></li>
            <?php
        }
        ?>
    </ul>

</div>

Read more here: Login and Logout Modal button add in Navwalker


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: