$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.244

Latest news

  • ProcessWire Weekly #558
    In the 558th issue of ProcessWire Weekly we'll check out the blog post that introduces ProcessWire 3.0.244, share some recent ProcessWire highlights, and more. Read on!
    Weekly.pw / 18 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer