get_posts accepts the same parameters as WP_Query, so you can always check the parameter documentation for that if you need help getting started. Here’s the documentation using author as a parameter for WP_Query: http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
Example (where 63 is the author’s user id)
$array = get_posts('author=63');
if(!empty($array)) {
// do stuff if they have posts
} else {
// do stuff if they don't have posts
}
is there any way this could be applied to all authors?
Ok, what exactly are you trying to do?
this code displays author avatar on pages that they post with links to their website. however it is showing a random avatar on profiles that havent posted anything yet.
so i wanted an if (author has posted) then display this code. else dont display this code
<a style="margin: 0px 25px" title="<?php the_author_meta( 'display_name' ); ?>s Website" alt="Author Webite Link"<a href="<?php the_author_meta( 'user_url' ); ?>"><?php echo get_avatar( get_the_author_meta('ID'), 150); ?></a></a>
Sure, just put your code where it says do stuff if they have posts.
$id = get_the_author_meta('ID');
$array = get_posts('author='.$id);
if(!empty($array)) {
// do stuff if they have posts
} else {
// do stuff if they don't have posts
}