2 Answers
2

This will check to see if the variable is empty first, and only run rsort() if it is not empty. This check works most of the time, but a false positive can sometimes occur if, for example, the variable is not actually an array but contains other data! (such as an error message). Alternatively, you may find this to work better in certain circumstances:

if ($post_dates != '') {
rsort($post_dates);
}

This will only continue if the variable does not equal null, which isn't quite the same thing as being empty. There are other ways to check if the variable is what you want, for example if (is_array($post_dates)) { do stuff }.

By feeding get_blog_details the blog ID number, you gain access to a whole range of properties, one of which being post_count for which you can use within the above if/else conditional statement to run a check before prior to executing your function.

Thus you can now display a different result set/piece of information in instances where a user has no posts and where they do have posts your regular code will execute as per normal.

Alternatively the count_user_posts() function could be used, however the above should suffice in this instance.