YT Sub Counter

وەسف

YT Sub Counter displays a YouTube “Subscribe” button with your channel’s live subscriber count, powered by the official YouTube subscribe button embed.

Add the button with the “YouTube Subscribe” block in the editor, or with the [ytsub] shortcode. The block works in posts, pages and the Site Editor, so you can drop it into a header, footer or sidebar template, or sit it in a Row next to core’s Social Icons block as one more social button.

Site-wide defaults are configured under Settings > YT Sub Counter:

  • Channel ID
  • Layout (default or full)
  • Theme (default or dark)
  • Subscriber count visibility (shown or hidden)

Every option on the block starts at “Use site default” and can be overridden on an individual block, or per shortcode: [ytsub theme="dark" count="hidden"].

The “Youtube Subscribers” widget is still included and existing widgets keep working, but it is legacy. Block themes have no widget areas at all, so the block is the way to place the button there.

External services

This plugin relies on Google’s YouTube subscribe button embed to render the live subscriber count and “Subscribe” button. This is a third-party/external service provided by Google.

On front-end pages that display a subscribe button, the plugin enqueues Google’s platform.js script from https://apis.google.com/js/platform.js. Pages with no block, shortcode or widget on them do not load it. Once loaded, that script (running in the visitor’s browser, not on your server) connects to YouTube/Google servers to render the subscribe button and fetch the channel’s live subscriber count. As with any embedded third-party script, this transmits the visitor’s IP address and standard browser/request data (such as the user agent and referring page) to Google, and may set Google cookies, in accordance with Google’s own policies.

No data is sent to Google from your server, and the plugin itself does not collect, store or transmit any personal data.

This service is provided by Google LLC:
* Terms of Service: https://policies.google.com/terms
* Privacy Policy: https://policies.google.com/privacy
* YouTube Terms of Service: https://www.youtube.com/t/terms

The script is required for the subscribe button to work, so there is no setting to disable it. Removing the block, shortcode and widget, or deactivating the plugin, stops it from loading.

سکرین شۆتەکان

بڵۆکەکان

ئەم پێوەکراوە 1 بڵۆک دابین دەکات.

  • YouTube Subscribe Your YouTube subscribe button with its live subscriber count.

دامەزراندن

  1. Upload the plugin files to the /wp-content/plugins/show-youtube-subscribers-count directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress.
  3. Go to Settings > YT Sub Counter and enter your YouTube Channel ID. You can find your Channel ID at https://www.youtube.com/account_advanced
  4. Edit any post, page or template and add the “YouTube Subscribe” block, or use the [ytsub] shortcode.

پهد

Nothing is displayed

Check that a Channel ID is set under Settings > YT Sub Counter, or directly on the block, shortcode or widget. The button is not rendered when no channel is configured.

The button shows an error

Make sure you’ve entered a valid YouTube Channel ID, not a custom URL or a handle beginning with @. Your Channel ID is the string starting with “UC” shown at https://www.youtube.com/account_advanced

I can’t find Appearance > Widgets

Block themes, including the recent default WordPress themes, do not have widget areas, so the Widgets screen does not exist for them. Use the “YouTube Subscribe” block instead. In the Site Editor you can add it to any template, including headers and footers, which is where a sidebar widget would once have gone.

How do I show it next to my other social icons?

Add a Row block, put core’s Social Icons block in it, then add the “YouTube Subscribe” block beside them. The Row’s alignment controls will line them up. The subscribe button is rendered by YouTube, so it keeps YouTube’s own styling rather than inheriting your social icon colours.

Is the widget going away?

Existing widgets keep working and there is no plan to remove the widget. It is no longer the recommended way to add the button, because WordPress itself has moved on from widget areas.

Can I show more than one channel?

Yes. Set the channel on the shortcode itself, for example [ytsub channel="UCxxxxxxxxxxxxxxxxxxxxxx"]. Any shortcode attribute overrides the site-wide setting.

What shortcode attributes are available?

channel, layout (default or full), theme (default or dark) and count (default or hidden). Anything you omit falls back to the setting saved under Settings > YT Sub Counter.

پێداچوونەوەکان

هیچ پێداچوونەوەیەک نەنووسراوە بۆ ئەم پێوەکراوە.

بەشداربووان و گەشەپێدەران

“YT Sub Counter” نەرمەواڵەیەکی سەرچاوە کراوەیە. ئەم کەسانەی خوارەوە بەشدارییان تێدا کردووە.

بەشداربووان

“YT Sub Counter” وەربگێڕە بۆ زمانەکەی خۆت.

دەتەوێت بەشداربیت لە گەشەپێدان؟

گەڕان لە کۆدەکەدا بکە، سەیری تەمارگەی (SVN) بکە، یان بەشداربە لە ڕووداوتۆماری گەشەپێدان لە ڕێگەی (RSS).

ڕووداوتۆمارگەریی گۆڕین

3.4.0

  • Improve: the settings screen is laid out in cards, with the channel and appearance options separated and instructions for the block, shortcode and widget alongside them.
  • New: a preview of the subscribe button on the settings screen that updates as you change layout, theme and count.
  • New: the block shows that same preview on the canvas, instead of a grey placeholder box, so it looks like what visitors will see.
  • New: the block uses the YouTube mark as its icon in the inserter and list view.
  • New: copy button for the [ytsub] shortcode, and help tabs on the settings screen.
  • Improve: a warning on the settings screen, and in the block, when no channel ID is set and nothing will be displayed.
  • Assets: plugin icon and header image for the plugin directory.

3.3.0

  • New: settings screen under Settings > YT Sub Counter for site-wide defaults.
  • New: “YouTube Subscribe” block, for posts, pages and the Site Editor. This replaces the widget on block themes, which have no widget areas, and can sit in a Row alongside the Social Icons block.
  • New: [ytsub] shortcode, for templates and other places blocks are not available.
  • New: Settings link on the plugins screen.
  • Improve: widget options left empty now fall back to the site-wide settings.
  • Fix: option values (default, full, dark, hidden) were passed through translation functions, which could break the button on non-English sites.
  • Harden: channel IDs and select values are validated against an allow list on save and on output.
  • Privacy: Google’s platform.js is now loaded only on pages that actually display a subscribe button, instead of on every front-end page.
  • Remove: an empty stylesheet and a placeholder script that were enqueued on every front-end page.
  • Docs: describe when platform.js is loaded, and correct the screenshot list.
  • Update: requires WordPress 6.3, for the block’s apiVersion 3 and iframe editor compatibility.
  • Update: tested up to WordPress 7.1.

3.1.1

  • Fix: “Tested up to” now correctly lists only the major WordPress version.
  • Docs: disclose the external YouTube/Google platform.js service in this readme.
  • I18n: text domain corrected to match the plugin slug (show-youtube-subscribers-count).
  • Security: escape the filtered widget title with esc_html() before output.
  • Fix: renamed the generic “google” script handle to the prefixed “ytsub-youtube-platform”.

3.1.0

  • Security: escape widget output (channel, layout, theme, count) with esc_attr() to prevent stored XSS via widget settings.
  • Fix: enqueue js/main.js as a script instead of a stylesheet.
  • Fix: correct asset URL resolution so css/js load from the plugin root.
  • Update: tested up to WordPress 7.0.2.

2.0.0

  • Add theme options dark and default.
  • Correct error when using a non custom YouTube URL.

1.0.0

  • Initial release.