mike131 Posted March 13, 2015 Share Posted March 13, 2015 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! Link to comment Share on other sites More sharing options...
kongondo Posted March 13, 2015 Share Posted March 13, 2015 (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 March 13, 2015 by kongondo 2 Link to comment Share on other sites More sharing options...
Wanze Posted March 13, 2015 Share Posted March 13, 2015 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. 4 Link to comment Share on other sites More sharing options...
kongondo Posted March 13, 2015 Share Posted March 13, 2015 Of course, how silly of me not to ask first ...Thanks Wanze Link to comment Share on other sites More sharing options...
mike131 Posted March 13, 2015 Author Share Posted March 13, 2015 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now