I am trying to display different information in my sidebar depending on which authors single post is being displayed. I have run into trouble, however, since the sidebar is outside the loop. How can I retrieve the author ID in this scenario?
Here is the code that I was trying to use until I realized that it was outside the loop.
$post_id = $post->ID;
$post_author = get_post($post_id);
$author = $post_author->post_author;
if ($author == "2"){
echo '1234';
} elseif ($author == "3"){
echo 'QQQQ';
} else {
echo 'abcd';
}