Counts_Command
View and manage post view counts.
EXAMPLES
# View top 10 posts by count
$ wp top10 counts view
# Get the count for a specific post
$ wp top10 counts get 42
Namespace: WebberZone\Top_Ten\Pro\CLI
Since: 4.3.0
Source: includes/cli/class-counts-command.php line 32
Extends: Base_Command
Methods
view()
List popular posts with their view counts.
OPTIONS
[—table=
] : Which table to query: overall, daily. Default: overall.[—limit=
[—from-date=
[—to-date=
[—post-type=
[—format=
[—network] : List popular posts for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 counts view
wp top10 counts view --table=daily --limit=20 --format=json
wp top10 counts view --from-date=2025-01-01 --to-date=2025-12-31
wp top10 counts view --network
Line: 73
public function view( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
get()
Get the view count for a specific post.
OPTIONS
[—table=
] : Which table to query: overall, daily. Default: overall.EXAMPLES
wp top10 counts get 42
wp top10 counts get 42 --table=daily
Line: 144
public function get( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
set()
Set the overall view count for a specific post.
OPTIONS
[—dry-run] : Show what would be changed without updating.
EXAMPLES
wp top10 counts set 42 1000
wp top10 counts set 42 1000 --dry-run
Line: 182
public function set( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
reset()
Reset (delete) view counts for one or more posts.
OPTIONS
[—post-id=
[—table=
] : Which table to reset: overall, daily, all. Default: all.[—force] : Skip interactive confirmation.
[—dry-run] : Show what would be deleted without deleting.
[—network] : Reset counts for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 counts reset --post-id=42,43 --table=overall
wp top10 counts reset --force
wp top10 counts reset --dry-run
wp top10 counts reset --network --force
Line: 240
public function reset( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
export()
Export view counts to a CSV file.
The output format matches the admin Import/Export page so files are interchangeable: Post ID, Visits, [Date,] Blog ID[, URL].
OPTIONS
[—file=
[—table=
] : Which table to export: overall, daily. Default: overall.[—limit=
[—include-urls] : Add a URL column (same as the admin “Include URLs in export” option).
[—dry-run] : Show how many rows would be exported without writing the file.
[—network] : Export rows for all sites in the network.
[—blog-id=
EXAMPLES
wp top10 counts export
wp top10 counts export --file=counts.csv --table=daily --limit=1000
wp top10 counts export --include-urls --network
wp top10 counts export --dry-run
Line: 329
public function export( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void
import()
Import view counts from a CSV file.
Accepts the same positional format produced by wp top10 counts export and
the admin Import/Export page: Post ID, Visits, [Date,] Blog ID[, URL].
The first row must be a header; its content is used to auto-detect whether
the file is for the overall or daily table (presence of a “Date” column).
OPTIONS
[—table=
] : Which table to import into: overall, daily. Default: auto-detected from header.[—use-urls] : Resolve the URL column to a post ID instead of using the Post ID column (matches the admin “Use URLs” option).
[—mode=
[—batch-size=
[—dry-run] : Parse the file and show a row count without writing anything.
[—force] : Skip interactive confirmation.
[—blog-id=
EXAMPLES
wp top10 counts import counts.csv
wp top10 counts import counts.csv --table=daily --dry-run
wp top10 counts import counts.csv --mode=set --force
wp top10 counts import counts-with-urls.csv --use-urls
wp top10 counts import counts.csv --blog-id=3
Line: 417
public function import( array $args, array $assoc_args ): void;
| Type | Name | Description |
|---|---|---|
array | $args | Command arguments. |
array | $assoc_args | Command associative arguments. |
Returns: void