Forums

[resolved] is_author() query - controlling sidebar for multiple authors (3 posts)

  1. edd_lasthours
    Member
    Posted 2 years ago #

    Hi,

    I'm hoping someone one here might be able to help!

    I'm currently working on a website that will have about 100 authors, all of whom need their own page. That's fine, but I want different groups (based on alphabet and what year they became authors in the project) to have different sidebars displayed. e.g. '2009'>'Authors A to G'

    I can do this for each individual author e.g.

    <?php elseif (is_author('63')) : ?>
    <div> do something relating to this authors</div>

    But I really don't fancy having 200 lines in sidebar.php just relating to these authors. Is there a way to put multiple ID numbers into one is_author conditional. e.g. if it's an author page ID 63, 64, 65 etc. then 'do something relating to these authors'?

    I've tried a couple of different permutations but I either get a php coding error on the front end or it just shows up blank.

    Any help gratefully received!

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    <?php
    if (is_author(array(1,2,42))) {
    echo 'this is either author 1,2, or 42';
    }
    ?>

    Conditional_Tags#An_Author_Page

  3. edd_lasthours
    Member
    Posted 2 years ago #

    Thanks so much. I thought I'd tried that, but clearly must have added some extraneous code somewhere. Anyhow, it's working perfectly now. Many thanks!!

Topic Closed

This topic has been closed to new replies.

About this Topic