Jump to content

Recommended Posts

Posted

Hi, I checked the docs and the forum but I was unable to see if there was a way to get the number of posts an author has.

Any ideas? Or did I miss something in the docs?

Thank you!

Posted (edited)

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
Posted

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
Posted

Thank you @kogondo.

I ended up using basically what you said with @Wanze's modification.

$cnt = $pages->count("template=foo, created_users_id=$author");

Thank you!

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
  • Recently Browsing   0 members

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