• Resolved Shafar

    (@shafar)


    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>';
    }
    ?>

    Thread Starter Shafar

    (@shafar)

    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.

    Thread Starter Shafar

    (@shafar)

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

    <?php the_title(); ?> By <?php the_author_posts_link(); ?>
    Thread Starter Shafar

    (@shafar)

    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 ‘How to Display Author-Name on all author posts except admin’s posts?’ is closed to new replies.