Pass post type to count_user_posts() in get_the_author_posts().
props Caspie, tyxla. fixes #30904. git-svn-id: https://develop.svn.wordpress.org/trunk@31098 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d5b99d560e
commit
907be55276
@ -197,7 +197,7 @@ function get_the_author_posts() {
|
||||
if ( ! $post ) {
|
||||
return 0;
|
||||
}
|
||||
return count_user_posts( $post->post_author );
|
||||
return count_user_posts( $post->post_author, $post->post_type );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,4 +82,21 @@ class Tests_User_Author extends WP_UnitTestCase {
|
||||
$GLOBALS['post'] = $this->post_id;
|
||||
$this->assertEquals( 1, get_the_author_posts() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30904
|
||||
*/
|
||||
function test_get_the_author_posts_with_custom_post_type() {
|
||||
register_post_type( 'wptests_pt' );
|
||||
|
||||
$cpt_ids = $this->factory->post->create_many( 2, array(
|
||||
'post_author' => $this->author_id,
|
||||
'post_type' => 'wptests_pt',
|
||||
) );
|
||||
$GLOBALS['post'] = $cpt_ids[0];
|
||||
|
||||
$this->assertEquals( 2, get_the_author_posts() );
|
||||
|
||||
_unregister_post_type( 'wptests_pt' );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user