• 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

Viewing 1 replies (of 1 total)
  • 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?

Viewing 1 replies (of 1 total)
  • The topic ‘Mulitple Authors – different sidebars’ is closed to new replies.