Jump to content

Author, get post count?


mike131
 Share

Recommended Posts

By posts I'll assume you mean pages....What you want is to count the number of pages created by the specified author, hence you want to use created_users_id in your selector. Below author can be an object or an ID

$cnt = $pages->find("template=foo, created_users_id=$author");
//find by current user
$cnt = $pages->find("created_users_id=$user");//you can also get the user first...

https://processwire.com/talk/topic/6423-all-items-from-member-on-member-page/

https://processwire.com/talk/topic/7403-module-blog/?p=85780

Edited by kongondo
  • Like 2
Link to comment
Share on other sites

A small addition to kongondos example: If you only need to get the count, you should use $pages->count("selector") because of performance reasons. The count method does not load the page objects.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...