WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to Display Author-Name on all author posts except admin’s posts?

[Resolved] How to Display Author-Name on all author posts except admin’s posts?

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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>';
    }
    ?>

    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!

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

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

    <?php the_title(); ?> By <?php the_author_posts_link(); ?>

    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! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] How to Display Author-Name on all author posts except admin’s posts?’ is closed to new replies.
Skip to toolbar