Title: Php help
Last modified: August 20, 2016

---

# Php help

 *  [posthawk](https://wordpress.org/support/users/posthawk/)
 * (@posthawk)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/)
 * i want to make an if then statement of
 * if author has posts
 * or posts>0
 * im not quite sure where to start

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Pioneer Web Design](https://wordpress.org/support/users/swansonphotos/)
 * (@swansonphotos)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367498)
 * Start here:
 * [http://codex.wordpress.org/Conditional_Tags](http://codex.wordpress.org/Conditional_Tags)
 *  [Andrew Bartel](https://wordpress.org/support/users/andrew-bartel/)
 * (@andrew-bartel)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367508)
 * 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](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
       }
       ```
   
 *  Thread Starter [posthawk](https://wordpress.org/support/users/posthawk/)
 * (@posthawk)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367519)
 * is there any way this could be applied to all authors?
 *  [Andrew Bartel](https://wordpress.org/support/users/andrew-bartel/)
 * (@andrew-bartel)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367527)
 * Ok, what exactly are you trying to do?
 *  Thread Starter [posthawk](https://wordpress.org/support/users/posthawk/)
 * (@posthawk)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367529)
 * 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>`
 *  [Andrew Bartel](https://wordpress.org/support/users/andrew-bartel/)
 * (@andrew-bartel)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367759)
 * 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
       }
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Php help’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [Andrew Bartel](https://wordpress.org/support/users/andrew-bartel/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/php-help-18/#post-3367759)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
