Support » How-To and Troubleshooting » Starting the Loop in header.php
10 years, 11 months ago
I’m hoping someone can help me here. I want to put the the_author_login in the header of my site. I just can’t work out how to start the loop in there. This is the code i’m using:
<?php if (is_home()) : ?>
Welcome: <?php the_author_login(); ?>
<?php endif; ?>
I’m sure the if clause is bad, but I couldn’t think of anything else to use. It shows the ‘Welcome:’ bit but not the_author_login – so I guess the loop isn’t working.
Any ideas what I’ve done wrong?
thanks in advance
From the codex: Displays the login name for the author of a post.
So….. how can it be in the header? It’s going to need to go with the posts that the author wrote….
That code breaks the posts and replaces it with ‘No Posts Found’, but does put what I wanted in the header.
But TechGnome is right I shouldn’t be using the_author_login, it’s the wrong tag. What I want to do is put the current logged in user’s name in the header – Welcome: Username
Do you know if this can be done?