WordPress.org

Ready to get started?Download WordPress

Forums

Mulitple Authors - different sidebars (2 posts)

  1. Steve Bruner
    Member
    Posted 5 years ago #

    Creating a blog that has four different authors. I want to show a different sidebar for:
    -author 1 archive & author 1 post(same sidebar)
    -author 2 archive & author 2 post(same sidebar)
    -author 3 archive & author 3 post(same sidebar)
    -author 4 archive & author 4 post(same sidebar)
    -home, category and tag (same sidebar)

    I've tried:

    <?php $post = $wp_query->post;?>
    
    <?php if ( $post->post_author == '1') { ?>
        hello author 1
    
    <?php } elseif ( $post->post_author == '2') { ?>
        hello author 2
    
    <?php } elseif ( $post->post_author == '3') { ?>
        hello author 3
    
    <?php } elseif ( $post->post_author == '4') { ?>
        hello author 4
    
    <?php } else { ?>
        default sidebar
    
    <?php } ?>

    But doesn't work. Only shows sidebar for author post, not author archive or any other pages.

    Any help would be greatly appreciated.

    Thanks
    Steve

  2. leadandfollow
    Member
    Posted 5 years ago #

    My guess is that $post->post_author only has a value for single posts, as the name of the variable suggests.

    For an author archive, you'd probably need a corresponding "author archive author". I do not know if WordPress has this functionality built in.

    Other types of pages would not have only a single author, right?

Topic Closed

This topic has been closed to new replies.

About this Topic