The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Starting the Loop in header.php (5 posts)

  1. hami
    Posted 10 years 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


  2. lynk
    Posted 10 years ago #

    Try this:

    if (have_posts()){

  3. TechGnome
    Posted 10 years ago #

    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....


  4. hami
    Posted 10 years ago #

    Thanks Lynx,

    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?



  5. lynk
    Posted 10 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic