Forums

[resolved] how to conditionally display the author's name (4 posts)

  1. nakris
    Member
    Posted 1 year ago #

    I'm setting up a site for a newspaper that has several authors. Each article displays the author's name, which is usually good, but there are also a number of articles for which the author name should not be displayed. I've been posting them from the admin account with a nickname of "Staff", so the byline reads "By Staff".

    What I'd like is to not display that at all.

    So, for articles whose author IS NOT "Staff", display the byline. For articles whose author IS "Staff", don't show anything in the byline area.

    I only understand enough php to construct things piecemeal, using snippets from examples and such. I can't figure this one out, though.

    Thanks in advance!

  2. MichaelH
    moderator
    Posted 1 year ago #

    Put this in your Loop and it will NOT print the post author if the user ID is 5. To find the user id for your Staff user look in your Users->Author&User panel.

    <?php
    if ('5' != $post->post_author) {
    the_author();
    }
    ?>
  3. nakris
    Member
    Posted 1 year ago #

    Perfect - exactly what I was looking for. Thanks very much!

  4. djr
    Member
    Posted 1 year ago #

    This has helped me a lot too, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic