What I'm trying to accomplish is the code will auto detect the Author ID <?php the_author_ID(); ?>
of the blogpost. Once it has the author ID, it will do a simple task. If the author # is equal to 2, call function sBadong. Else, if author ID is equal to 3, call function sJade. if two condition was not met, call function sBen.
here's my code, but it's not working. I dunno what wrong's with it. can you help?
<?php
$author_id=$post->post_author;
if ($author_id == "2") {
echo sBadong();
} elseif ($author_id == "3") {
echo sJade();
} else {
echo sBen();
}
?>
The problem with the code above is it's not reading the Author Number of the post. It always returning the function sBen(); and ignore all if and else statements.
php $author_id=$post->post_author; ?> it will give you current author id.
The easiest way to add an author photo in WordPress is by using the PublishPress Authors plugin. This plugin lets authors edit their own profile and author photo by adding a new 'Author Profile' area to their WordPress dashboard.
get_the_ID() Retrieves the ID of the current item in the WordPress Loop.
Please use function as following:
$author_id = get_post_field ('post_author', $post_id);
It will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With