Forums

[resolved] conditionalizing the_author function (3 posts)

  1. Gouri
    Member
    Posted 2 months ago #

    Mine is a single author blog http://www.ezaroorat.com I want to introduce guest posts on it. But I do not want the guest author to be registered in the admin panel. On the guest posts, I want to hide my (default author) name. Is it possible to conditionalize the_author function so that the author name is hidden on guest posts only but displayed on all other posts? (By imposing some kind of conditions based on tag or custom field).

  2. MichaelH
    moderator
    Posted 2 months ago #

    For use in The Loop:

    <?php
    //if guest_author custom field is present don't display the author.
    $guest_author = get_post_meta($post->ID, 'guest_author', true);
    if (!$guest_author){
    the_author();
    }
    ?>
  3. Gouri
    Member
    Posted 2 months ago #

    That's really great!! MichaelH, thank you so much. I have implemented it & am now ready to take my flight.

Reply

You must log in to post.

About this Topic