Top 10 v3.0.0 introduced Top_Ten_Query, which works as a wrapper for WP_QueryOpens in a new window. This brings all the power and flexibility of WP_Query to Top 10. If you’re not familiar with WP_Query, I recommend reading the documentationOpens in a new window.
Standard Loop
get_tptn_posts()
get_tptn_posts() is a wrapper to Top_Ten_Query. You can use it to retrieve an array of the popular posts. It also accepts the same $args as Top_Ten_Query.
Data source
Queries follow the Data source setting. In Hybrid and Koko Analytics only modes, lists use Koko Analytics page views. Date boundaries resolve to whole days, and overall counts cover only retained Koko Analytics data.
Top 10 Pro can query other network sites; sites without usable Koko Analytics data fall back to Top 10 counts. The free plugin restricts queries to the current site.
Parameters
In addition to the WP_Query parametersOpens in a new window, Top_Ten_Query also takes these additional parameters.
| Parameter | Type | Description |
|---|---|---|
blog_id | array or string | Array or comma-separated string of blog IDs. Lists across several sites need Top 10 Pro; the free plugin uses the current site. |
daily | bool | Set to true to fetch daily or custom period posts. Set to false for the overall popular posts. |
daily_range | number | Enter the number of days, e.g. set it to 7 to fetch the popular posts in the past week. |
include_cat_ids | array or string | Array or comma-separated string of categories or term_taxonomy_ids. |
include_post_ids | array or string | Array or comma-separated string of post IDs to include. |
offset | int | Offset the related posts returned by this number. |
strict_limit | bool | If false, fetches up to 3× the limit to allow filtering. |

Blocks in Top 10