WordPress.org

Make WordPress Core

Changeset 31098


Ignore:
Timestamp:
01/08/15 19:52:52 (3 years ago)
Author:
SergeyBiryukov
Message:

Pass post type to count_user_posts() in get_the_author_posts().

props Caspie, tyxla.
fixes #30904.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/author-template.php

    r30105 r31098  
    198198        return 0; 
    199199    } 
    200     return count_user_posts( $post->post_author ); 
     200    return count_user_posts( $post->post_author, $post->post_type ); 
    201201} 
    202202 
  • trunk/tests/phpunit/tests/user/author.php

    r28362 r31098  
    8383        $this->assertEquals( 1, get_the_author_posts() ); 
    8484    } 
     85 
     86    /** 
     87     * @ticket 30904 
     88     */ 
     89    function test_get_the_author_posts_with_custom_post_type() { 
     90        register_post_type( 'wptests_pt' ); 
     91 
     92        $cpt_ids = $this->factory->post->create_many( 2, array( 
     93            'post_author' => $this->author_id, 
     94            'post_type'   => 'wptests_pt', 
     95        ) ); 
     96        $GLOBALS['post'] = $cpt_ids[0]; 
     97 
     98        $this->assertEquals( 2, get_the_author_posts() ); 
     99 
     100        _unregister_post_type( 'wptests_pt' ); 
     101    } 
    85102} 
Note: See TracChangeset for help on using the changeset viewer.