WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to Display Author-Name on all author posts except admin's posts? (7 posts)

  1. Shafar
    Member
    Posted 4 years ago #

    Hi, I have a multi-authored blog. How can I display the author-name and author-url at the beginning of all posts EXCEPT the posts written be me(admin)? Please help!

    I guess we can do this using CONDITIONAL TAGS.

  2. MichaelH
    Member
    Posted 4 years ago #

    In a loop

    <?php
    $author = get_userdata($post->post_author);
    if ($author->user_login != 'admin') {
      echo '<p>Display name '.$author->user_login .'</p>';
      echo '<p>URL '.$author->user_url .'</p>';
    }
    ?>
  3. Shafar
    Member
    Posted 4 years ago #

    Thanks for the quick reply. It's working fine. But I would like to display just one line like:
    Guest Post by AUTHOR_NAME (AUTHOR_NAME linking to AUTHOR URL)

    Please help!

  4. MichaelH
    Member
    Posted 4 years ago #

    Please paste the code from template that you are using to display your posts into a pastebin and report the link back here.

  5. Shafar
    Member
    Posted 4 years ago #

    My single.php template:
    http://pastebin.com/s49gGp3E

  6. MichaelH
    Member
    Posted 4 years ago #

    <?php the_title(); ?> By <?php the_author_posts_link(); ?>
  7. Shafar
    Member
    Posted 4 years ago #

    Hey I framed it myself using your loop.

    <?php
    $author = get_userdata($post->post_author);
    if ($author->user_login != 'admin') {
    echo '<p>Guest Post by <a href="'.$author->user_url .'">'.$author->user_login .'</a>';
    }
    ?>

    Thanks for guiding me! :)

Topic Closed

This topic has been closed to new replies.

About this Topic