Linux 软件免费装
Banner图

Init View Count – Minimal, Accurate, Extensible

开发者 brokensmile.2103
更新时间 2025年6月26日 18:28
PHP版本: 7.4 及以上
WordPress版本: 6.8
版权: GPLv2 or later
版权网址: 版权信息

标签

shortcode views counter post views rest api

下载

1.8 1.6 1.10 1.5 1.7 1.9

详情介绍:

Init View Count is a fast, clean plugin to track post views without clutter. It: This plugin is part of the Init Plugin Suite — a collection of minimalist, fast, and developer-focused tools for WordPress. GitHub repository: https://github.com/brokensmile2103/init-view-count

安装:

  1. Upload plugin to /wp-content/plugins/init-view-count/
  2. Activate via Plugins menu
  3. Use [init_view_count] or [init_view_list] in your content
  4. Customize settings in Settings → Init View Count

屏幕截图:

  • Shortcode builder for [init_view_list] – generate view-based post lists with custom templates.
  • Shortcode builder for [init_view_ranking] – generate tabbed rankings for different view ranges.
  • Shortcode builder for [init_view_count] – display view count for current post with format options.
  • Frontend view – ranking display (all time), light mode interface.
  • Frontend view – ranking display (this week), dark mode interface.

常见问题:

Can I reduce the number of view requests sent to the server?

= 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.
= Can I disable the built-in CSS? =\ Yes. There is an option in the plugin’s settings to disable the default stylesheet. You can style the output manually as needed. = Is it compatible with caching plugins? =\ Yes. Since it uses JavaScript + REST for counting, page caching doesn't interfere. However, REST responses (/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.

更新日志:

1.10 – June 26, 2025 1.9 – June 24, 2025 1.8 – June 22, 2025 1.7 – June 21, 2025 1.6 – June 19, 2025 1.5 – June 16, 2025 1.4 – June 8, 2025 1.3 – June 7, 2025 1.2 – June 5, 2025 1.1 – May 28, 2025 1.0 – May 18, 2025