Make WordPress Core

Opened 9 years ago

Closed 5 months ago

Last modified 4 months ago

#31677 closed defect (bug) (invalid)

count_user_posts is not working in wordpress 4.1

Reported by: starkmanish's profile stark.manish Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: Posts, Post Types Keywords: reporter-feedback needs-testing
Focuses: Cc:


count_user_posts have two parameters.

  1. User ID
  2. Post Type.

There is a note in codex - Note : Since 4.1 it supports post types.

But when I am using this function in my recent wordpress version i.e. 4.1 it is not giving me proper output.

Codex Url -

Change History (8)

#1 @boonebgorges
9 years ago

  • Component changed from General to Posts, Post Types
  • Keywords reporter-feedback added

stark.manish - Can you please give additional details? Exactly how are you calling count_user_posts()? What do you expect to get as a return value? And what are you in fact getting?

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

No feedback in 5 months. Feel free to reopen with more information if there's still an issue.

#3 @jberculo
7 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I am having problems too. The function is accepting a second parameter, but it seems to ignore it. I am calling the function as follows:

echo count_user_posts($author_id, $post_type);

This always results in the amount of posts for the default post type being returned, instead of the actual count for the supplied post type.

I am using Wordpress 4.8

#4 @SergeyBiryukov
7 years ago

  • Milestone set to Awaiting Review

#5 @nishitlangaliya
7 years ago

  • Keywords needs-testing added

@jberculo ,@SergeyBiryukov,

echo count_user_posts($author_id, $post_type);

Works for me, I tested with echo count_user_posts('1', 'product');
it gave me perfect count for post type product. Please check for the same and let me know if i am missing.


#6 @nishitlangaliya
7 years ago

ignore previous comment. I tested with 4.8

Last edited 7 years ago by nishitlangaliya (previous) (diff)

#7 @rodrigosprimo
5 months ago

  • Resolution set to invalid
  • Status changed from reopened to closed

Closing as there has been no feedback in a few years. I tested and was not able to reproduce the issue. Feel free to reopen with more information if there's still an issue.

#8 @swissspidy
4 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.