Get the number of pageviews for a given post ID.

Default to the current post.


Name Type Description
$post_id int Optional. The post ID to fetch stats for. Defaults to the $post global's value.
$num_days int Optional. How many days to go back to include in the stats. Default is 1. Maximum 90 days.
$end_data string Optional. The last day of the desired time frame. Format is 'Y-m-d' (e.g. 2007-05-01) and default is today's UTC date.

Return Value

int|false: Number of pageviews or false on error.

Ready to get started?

Tell us about your needs

Let us lead the way. We’ll help you select a top tier development partner. We’ll train your developers, operations, infrastructure, and editorial teams. We’ll coarchitect your deployment processes. We will provide live support for peak events. We’ll help your people avoid dark alleys and blind corners, and reduce wasted cycles.