| 开发者 | brokensmile.2103 |
|---|---|
| 更新时间 | 2026年7月17日 22:52 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
_init_view_count, _init_view_day_count, etc.[init_view_count] and [init_view_list] shortcodes[init_view_ranking] shortcode with tabbed ranking by time range[init_view_list] via the page attribute/wp-content/plugins/init-view-count/[init_view_count] or [init_view_list] in your content= Can I customize the layout of the list? =\
Yes. Use the template attribute in [init_view_list] (e.g. template="grid"), and override the corresponding file in your theme like WooCommerce templates.
= Does it work with custom post types? =\
Yes. Just set post_type="your_custom_type" in the shortcode or REST query.
= How does it avoid duplicate views? =\
Init View Count uses both time delay and scroll detection via JavaScript, and stores viewed post IDs in either sessionStorage or localStorage (your choice).
= Is the view count updated immediately? =\
Yes. When the scroll+delay conditions are met, the count is updated via REST API and saved using update_post_meta().
= What meta key is used to store views? =\
By default:
_init_view_count (total)_init_view_day_count_init_view_week_count_init_view_month_count\
These keys can be changed via the init_plugin_suite_view_count_meta_key filter.
Trending scores are calculated separately and stored in a transient.
= Can I display view counts in my template manually? =\
Yes. Use get_post_meta($post_id, '_init_view_count', true) or similar keys. Or use [init_view_count] shortcode in post content./top) are cached using transients.
= Can I use it in block editor / Gutenberg? =\
Yes. Just insert a Shortcode block and paste [init_view_count] or [init_view_list] as needed.
= Does it track bots? =\
No. Since counting only happens after scroll and delay via JavaScript, bots like Googlebot are naturally excluded.
= Can I sort posts by views in WP_Query? =\
Yes. Use 'meta_key' => '_init_view_count' and 'orderby' => 'meta_value_num' in your WP_Query args.
Yes. You can enable batch view tracking in the plugin settings. Instead of sending one request per view, views will be stored in the browser and sent in a group once the threshold is reached.
It's optional and off by default. Enabling it makes the /count endpoint reject requests that don't carry a valid WordPress REST nonce, which helps block fake POST requests sent directly to the endpoint. However, WordPress nonces expire after roughly 12-24 hours. If your site uses full-page caching with a long TTL, cached pages will keep serving an old nonce and view counting will quietly stop working on those pages until the cache refreshes. Leave it off on sites with long-lived page caching, or make sure the cache is purged/refreshed regularly. The /top endpoint is unaffected either way, since it's read-only and public by design.
POST /count requires a valid X-WP-Nonce header and rejects the request with 403 otherwise, helping block direct spam POSTs to the endpoint that skip loading the page first.GET /top is intentionally excluded, since it's a read-only, public-by-design endpoint.Invalid post ID., Not enabled for view counting.) plus all new strings from this release to languages/init-view-count.pot, with ready-made Vietnamese translations in languages/init-view-count-vi.po / .mo./count REST endpoint:total, day, week, month) are now incremented with a direct, atomic SQL UPDATE ... SET meta_value = meta_value + 1 instead of a read-then-write get_post_meta() + update_post_meta() pair, removing a race condition that could drop views under concurrent trafficcached value + 1) instead of re-querying the database after the write, saving a query per counted keyget_option()/update_option() call on shutdown, instead of once per counted post — meaningful reduction in option writes on sites using batch view trackingphpcs:ignore justifications, no behavior change to existing filters/actions)init_plugin_suite_view_count_enable_day → default = 1init_plugin_suite_view_count_enable_week → default = 1init_plugin_suite_view_count_enable_month → default = 1_init_view_day_yesterday, _init_view_week_last, _init_view_month_last[init_view_ranking]:yesterday, last_week, last_monthtotal,day,week,month) for compatibilityinit_plugin_suite_view_count_top):range parameter extended with yesterday, last_week, last_monthinit_plugin_suite_view_count_meta_key for extensibilityinit_plugin_suite_view_count_site_traffic_shape provides current hour/day shape arraysinit_plugin_suite_view_count_shape_collect_enabled allows enabling/disabling collectioninit_plugin_suite_view_count_shape_reset to clear all learned shape dataviews_day_used and fallback flags for transparencyinit_plugin_suite_view_count_trending_debug_row available for developers to log detailed trending rowsinit_plugin_suite_view_count_trending_component_weights, init_plugin_suite_view_count_meta_key)init_plugin_suite_view_count_trending_post_types – limit/override post types (e.g., only manga)init_plugin_suite_view_count_trending_component_weights – adjust weights for velocity, engagement, freshness, momentumattachment, safe fallback when emptyinit_plugin_suite_view_count_top_post_types filter to allow overriding post_type in top view REST API routemanga, article, etc.)[init_view_count] now supports id="..." attribute to display the view count of any post (not just the current one)id is omitted, the current post will be used as before[init_view_ranking] now supports post_type="..." to filter rankings by custom post typeranking.js updated to pass post_type to REST API and cache results per tab and typeinit_plugin_suite_view_count_human_time_diff() in favor of core human_time_diff()[init_view_count] shortcode to use native human_time_diff() for publishing time displayhuman_time_diff() instead of removed custom functionicon="true" attribute to [init_view_count] shortcode to display inline SVG before the view countschema="true" attribute to [init_view_count] to output Schema.org microdata (InteractionCounter)class="custom-class" attribute to allow injecting custom CSS classes into the shortcode wrapperinit_plugin_suite_view_count_default_shortcode allows developers to override default auto-insert outputinit_plugin_suite_view_count_auto_insert_enabled gives control over whether auto-insert is active per contextmatch expressions with backwards-compatible logic using array maps and switchesinit_plugin_suite_view_count_meta_key and template behavior[init_view_list], and [init_view_count] shortcodesinit-shortcode-builder.js with full shortcode configuration UI[init_view_list], [init_view_ranking], and [init_view_count] shortcodesInitViewCountShortcodeBuilder.i18nrange=trending support added to /top REST endpoint with built-in sorting and pagination[init_view_list range="trending"] now fetches trending posts[init_view_ranking] shortcode to display tabbed ranking UI by day/week/month/all-timestyle.cssstyle.css earlier to avoid being printed in the footerinit_plugin_suite_view_count_meta_key consistently across REST API, shortcodes, and background taskspage parameter to /top REST endpoint for paginationpage attribute to [init_view_list] shortcode for paginated lists