Getting different functions data while using while loop in wordpress

Question

I have added this code in the function.php file but when I use while loop in any other files this function is getting triggered.

<?php
add_action('loop_start', 'userlogin');
function userlogin()
{
if (is_user_logged_in()) :
$current_user = wp_get_current_user();
?>
    <div class="dropdown na-dropdown">
        <button class="na-btndropdown" id="na-dropdowndashboard" type="button" data-toggle="dropdown">
            <img src="<?php echo esc_url(get_avatar_url($current_user->ID)); ?>" alt="User Image">
            <span><?php echo $current_user->display_name; ?> </span>

            <i class="fa fa-caret-down"></i>
        </button>
        <ul class="dropdown-menu na-dropdownusermenu" aria-labelledby="na-dropdowndashboard">
            <li><a href="<?php echo get_dashboard_url(); ?>">Dashboard</a></li>
            <li><a href="<?php echo get_edit_profile_url(); ?>">Edit Profile</a></li>
            <li><a href="<?php echo wp_logout_url(); ?>">Sign Out</a></li>
        </ul>
    </div>
<?php else : ?>
    <a id="na-btnsignin" class="na-btn" href="<?php echo wp_login_url(); ?>"><span>Login</span></a>
<?php endif;
}
?>

The above function value is getting loaded where I have used While loop.

<?php
while ($the_query->have_posts()) {
$the_query->the_post();              
 ?>

0
Nabeen 6 months 2022-03-04T11:05:03-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse