Make WordPress Core

Opened 10 years ago

Closed 14 months ago

Last modified 13 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:

Description

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 - http://codex.wordpress.org/Function_Reference/count_user_posts

Change History (8)

#1 @boonebgorges
10 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
10 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
8 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:

<?php
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
8 years ago

  • Milestone set to Awaiting Review

#5 @nishitlangaliya
8 years ago

  • Keywords needs-testing added

@jberculo ,@SergeyBiryukov,

<?php
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.

Thanks.

#6 @nishitlangaliya
8 years ago

ignore previous comment. I testes with 4.8

Version 0, edited 8 years ago by nishitlangaliya (next)

#7 @rodrigosprimo
14 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
13 months ago

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