$pages->count() method

Count and return how many pages will match the given selector.

If no selector provided, it returns count of all pages in site.

Example

// Return count of how may pages in the site use the blog-post template
$numBlogPosts = $pages->count("template=blog-post");

Usage

// basic usage
$int = $pages->count();

// usage with all arguments
$int = $pages->count($selector = '', $options = []);

Arguments

NameType(s)Description
selector (optional)string, array, Selectors

Specify selector, or omit to retrieve a site-wide count.

options (optional)array, string

See $options for $pages->find().

Return value

int

See Also


$pages methods and properties

API reference based on ProcessWire core version 3.0.135

Twitter updates

  • New post: A look at two new WireMail modules for sending email, plus details on how you can configure ProcessWire to use Gmail for sending email— More
    19 July 2019
  • New post: Version 3.0.135 of ProcessWire on the dev branch focuses on some .htaccess updates, adds clarity to debug mode, and improves upon the installer— More
    5 July 2019
  • ProcessWire 3.0.133 adds a useful new Page::meta() method for a new type of page-specific persistent data storage, adds the ability for users to create their own bookmarks in Lister, and has a handy and time saving update for the asmSelect input type— More
    14 June 2019

Latest news

  • ProcessWire Weekly #271
    In the 271st issue of ProcessWire Weekly we're going to introduce two brand new WireMail modules, a new Textformatter module from BitPoet, and a brand new markup module from Chris Thomson. Read on!
    Weekly.pw / 20 July 2019
  • Two new WireMail modules and using Gmail with PW
    A look at two new WireMail modules for sending email, plus details on how you can configure ProcessWire to use Gmail for sending email.
    Blog / 19 July 2019
  • Subscribe to weekly ProcessWire news

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.