Make WordPress Core

Ticket #27998: 27998.diff

File 27998.diff, 496 bytes (added by krogsgard, 12 years ago)

Perform a check on get_post() within get_the_author_posts() to avoid a notice.

  • wp-includes/author-template.php

    diff --git wp-includes/author-template.php wp-includes/author-template.php
    index dd225c0..9447ebb 100644
    function the_author_link() { 
    206206 * @return int The number of posts by the author.
    207207 */
    208208function get_the_author_posts() {
    209         return count_user_posts( get_post()->post_author );
     209        $post = get_post();
     210        if ( empty( $post ) ) {
     211                return 0;
     212        }
     213        return count_user_posts( $post->post_author );
    210214}
    211215
    212216/**