Category Popular Tags

Description

Category Popular Tags gives you a fully styled set of tag buttons that can appear anywhere on your WordPress site — category archives, tag archives, author archives, individual pages, WooCommerce product category pages, or embedded directly in post content via shortcode.

There are two types of buttons you can create:

  • Auto Popular Tags — the plugin queries your posts and surfaces the most-used tags for a given category, ordered by frequency. Drop the shortcode anywhere and it works: on a category archive it shows that category’s popular tags; on any other page it automatically falls back to your site-wide most popular tags.

  • Custom Buttons — build a hand-picked set of tag buttons with your own labels, URLs, and optional icon images. Drag them into any order and use the generated shortcode to place them exactly where you want.

Both button types share the same global style system, so one set of controls governs the look of everything: colours, hover states, font size, weight, border radius, padding, icon size, column count, gap, box shadow, and text transform.

Admin Panel — Four Tabs

Tab 1 — Custom Buttons

Manually create and manage a list of styled buttons. Each row has:

  • An optional icon image (uploaded via the WordPress media library)
  • A text label
  • A URL

Rows are drag-and-drop reorderable. Once saved, the tab shows a ready-to-copy shortcode. You can also display a specific subset of buttons in any order using [cpt_buttons ids="3,1,2"].

Tab 2 — Auto Popular Tags

Configure the automatic tag discovery:

  • Set the section title shown above the buttons
  • Set the default number of tags to display
  • Toggle sequential number badges on each button
  • Choose the cache duration (1 hour, 12 hours, 1 day, or 1 week)

A live preview section lets you pick any category from a dropdown and see exactly how the tags will look on the front end — before saving anything. After loading a preview the tab shows you a category-specific shortcode (e.g. [popular_category_tags category_id="3"]) ready to copy.

Tab 3 — Style

Every visual property of the buttons is controlled here:

  • Button background colour and hover background colour
  • Font colour and hover font colour
  • Border colour, border width, and border radius
  • Font size, font weight, and text transform (none / uppercase / capitalize)
  • Padding (top/bottom and left/right independently)
  • Icon size and the gap between the icon and the label text
  • Gap between buttons on desktop and on mobile independently
  • Column count on desktop (auto-fit, 1, 2, 3, or 4) and on mobile (1 or 2)
  • Box shadow toggle

A real-time preview updates as you drag sliders and pick colours — no save required to see the effect.

Tab 4 — Placement

Control where tags appear automatically, without touching any shortcode or theme file:

  • Category archives — before posts, after posts, both, or after the page title (a JavaScript-based injection that works on any theme)
  • Tag archives — show site-wide popular tags on tag archive pages
  • Author archives — show site-wide popular tags on author archive pages
  • Exclude categories — prevent automatic display on specific categories
  • WooCommerce (shown only when WooCommerce is active) — auto-display before or after products on product category pages

Shortcodes

Auto popular tags — simplest form:
[popular_category_tags]

Used on a category archive shows popular tags for that category.
Used anywhere else shows your site-wide most popular tags automatically.

With specific category:
[popular_category_tags category_id=”5″]

With count and custom title:
[popular_category_tags count=”8″ category_id=”5″ title=”Browse by Topic”]

All available attributes:

  • category_id — the ID of the category to pull tags from. Omit to auto-detect or fall back to site-wide.
  • count — number of tags to show. Omit to use the admin default.
  • title — override the section heading for this instance only.
  • verbose — set to 1 to output HTML comments useful for debugging.

Custom curated buttons:
[cpt_buttons]

All buttons in saved order.

[cpt_buttons ids="3,1,2"]

Specific buttons in a specific order.

Template Functions

For theme developers who prefer PHP over shortcodes:

cpt_popular_tags( $args )

Renders auto popular tags. Accepts an optional array to override admin defaults:

cpt_popular_tags( array(
    'category_id' => 5,
    'count'       => 6,
    'title'       => 'Related Topics',
) );

cpt_custom_buttons( $args )

Renders the custom buttons created in Tab 1. Accepts an optional ids array to filter and reorder:

cpt_custom_buttons( array( 'ids' => array( 3, 1, 2 ) ) );

Backwards Compatibility

If you were using the plugin before version 2.0, nothing breaks:

  • [popular_category_tags] and all its original attributes (count, category_id, category_name, type) work exactly as before.
  • The legacy theme function cush_category_popular_tag() is still available as an alias for cpt_popular_tags().
  • Existing settings are automatically migrated on upgrade — no manual action required.

Credit

Popular tag query logic originally inspired by:
https://wordpress.stackexchange.com/questions/261617/display-most-popular-tags-of-category

Screenshots

  • Custom Buttons tab — add, reorder, and manage curated tag buttons with icon upload
  • Auto Popular Tags tab — settings, live category preview, and auto-generated shortcode
  • Style tab — full button style controls with real-time preview panel
  • Placement tab — automatic display settings for archives and WooCommerce
  • Front-end display — styled popular tag buttons on a category archive page
  • Front-end display — custom curated buttons with icons on a regular page

Installation

From the WordPress admin:

  1. Go to Plugins Add New.
  2. Search for “Category Popular Tags”.
  3. Click Install Now, then Activate.
  4. Go to Settings Category Tags to configure.

Manual upload:

  1. Download the plugin zip file.
  2. Upload and extract it to /wp-content/plugins/category-popular-tags/.
  3. Activate through the Plugins screen in WordPress.
  4. Go to Settings Category Tags to configure.

FAQ

I just placed [popular_category_tags] on a regular page — nothing shows up. What’s wrong?

Nothing is wrong. In version 2.0+ the shortcode automatically falls back to your site-wide most popular tags when it cannot detect a category. If you’re seeing a blank result it means your posts have no tags at all yet. Add tags to some posts and the shortcode will display them.

How do I find a category’s ID?

Go to Posts Categories, hover over the category name and look at the URL in your browser’s status bar. You will see tag_ID=5 — the number is the category ID. You can also use the preview tool in the Auto Popular Tags tab: select a category from the dropdown and the category-specific shortcode (with the ID already filled in) appears after loading the preview.

What is the difference between Custom Buttons and Auto Popular Tags?

Auto Popular Tags are generated automatically by querying which tags appear most often on posts within a category (or site-wide). The list updates as your content changes (subject to the cache duration).

Custom Buttons are entirely hand-curated. You decide the label, the URL, and the icon. They never change unless you edit them in the admin. Use these when you want precise control — for example, a fixed “Gifts Under £20” button that links to a specific tag or page regardless of what is trending.

How do I show tags for a specific category no matter what page the shortcode is on?

Use the category_id attribute: [popular_category_tags category_id="5"]. This locks the shortcode to that category everywhere it appears.

Can I display the tags automatically without a shortcode?

Yes. Go to Settings Category Tags Placement. Enable “Auto-display on category archive pages” and choose a position. You can also enable auto-display on tag archives, author archives, and (if WooCommerce is active) product category pages — all without touching any shortcode or theme file.

What does the “After Title” position do and when should I use it?

“After Title” injects the tags immediately below the category page heading using a small JavaScript snippet that runs when the page loads. Because it targets the heading element in the DOM rather than relying on a specific WordPress action hook, it works on virtually any theme — including those where “Before Posts” or “After Posts” cause layout problems. Use it when the other positions don’t sit in the right place visually.

The tags aren’t updating after I published new posts. Why?

The plugin caches tag query results to avoid running expensive database lookups on every page view. The default cache duration is one day. You can shorten this in Settings Category Tags Auto Popular Tags Cache Duration, or force an immediate refresh by saving the settings page (which clears all caches automatically).

How do I show a different number of tags in one place than another?

Use the count attribute in your shortcode: [popular_category_tags count="10"]. This overrides the default count set in the admin for that specific instance only. The admin default is used whenever count is omitted.

Can I use the plugin in a page builder like Elementor or Divi?

Yes. Both shortcodes ([popular_category_tags] and [cpt_buttons]) work in any shortcode-compatible widget or block. In Elementor use a Shortcode widget; in Divi use a Code module.

Can I add the plugin output to my theme template files directly?

Yes. Use the PHP template functions:

cpt_popular_tags();
cpt_custom_buttons();

Both functions accept an optional $args array. Place them in category.php, archive.php, single.php, or any other template file.

Does the plugin work without WooCommerce?

Completely. WooCommerce support is an optional layer that only activates when WooCommerce is installed and active. If WooCommerce is not present, the plugin behaves identically — the WooCommerce section simply does not appear in the Placement tab.

Does the plugin slow down my site?

No. Tag query results are stored in WordPress transients (database-level cache) for the duration you configure. On cached requests there is no extra database query at all. The only time a query runs is when the cache has expired or been cleared.

My icon images look stretched or blurry. How do I fix this?

Go to Settings Category Tags Style and adjust the Icon Size slider to match the natural dimensions of your icon images. Square icons (equal width and height) always produce the cleanest result. The plugin uses object-fit: contain so images are never cropped, but if the icon size is much larger than the source image it may appear soft.

How do I reorder the custom buttons?

In Settings Category Tags Custom Buttons, grab the drag handle (the grid icon on the left of each row) and drag the row up or down. Click Save Buttons when done. The new order is reflected everywhere [cpt_buttons] is used.

Can I show only some of my custom buttons in a specific place?

Yes. Each button has a numeric ID shown implicitly by its position. Use the ids attribute to specify which ones to show and in what order: [cpt_buttons ids="2,5,1"]. The ID of each button is assigned when you save — you can find the generated shortcode on the Custom Buttons tab after saving.

The style changes I made aren’t appearing on the front end.

Try these in order: (1) save the Style tab again — this clears the style cache. (2) Hard-refresh your browser (Ctrl+Shift+R / Cmd+Shift+R). (3) If you use a caching plugin (WP Super Cache, W3 Total Cache, LiteSpeed Cache, etc.) purge its cache after saving. The plugin outputs styles inline and scoped to each button container, so theme stylesheet caching should not interfere, but page-level caches will serve the old HTML until purged.

Is this plugin compatible with multisite?

The plugin stores settings per-site using standard get_option / update_option calls, so it works correctly on WordPress multisite. Each site in the network has its own independent settings and button lists.

Will this plugin affect my site’s SEO?

Tag links rendered by the plugin are standard <a href> elements pointing to your tag archive URLs. They are follow links by default, which means search engines can crawl them. If you want to prevent specific tag archives from being indexed, manage that through your SEO plugin (Yoast, Rank Math, etc.) — it is outside the scope of this plugin.

How do I uninstall the plugin cleanly?

Deactivate the plugin, then click Delete on the Plugins screen. The plugin’s uninstall.php will automatically remove all options (cpt_options, cpt_custom_buttons) and all cached transients from the database. Nothing is left behind.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Category Popular Tags” is open source software. The following people have contributed to this plugin.

Contributors

Change log

2.0.0

  • Complete rewrite — consistent naming, professional code quality throughout
  • New: tabbed admin panel with four dedicated tabs
  • New: Custom Buttons builder — icon upload, label, URL, drag-to-reorder
  • New: global Style tab — 16 visual controls with real-time live preview
  • New: Placement tab — auto-inject on category, tag, and author archives
  • New: “After Title” placement position via JavaScript DOM injection
  • New: WooCommerce product category page support (auto-detected)
  • New: [cpt_buttons] shortcode and ids attribute for selective display
  • New: cpt_popular_tags() and cpt_custom_buttons() theme template functions
  • New: site-wide popular tags fallback when no category context is detected
  • New: configurable cache duration replacing hard-coded transient expiry
  • New: AJAX save on all forms — no full page reload required
  • New: category preview with auto-generated copy-ready shortcode suggestion
  • New: copy-to-clipboard button on all shortcode references
  • Fix: extract() security risk removed — attributes now handled explicitly
  • Fix: PHP parse error in shortcode class (else block outside if)
  • Fix: transient key collision between categories with the same name resolved
  • Fix: stylesheet version was time() on every request — now uses plugin version
  • Fix: register_deactivation_hook now uses $wpdb->options instead of hard-coded table name
  • Backwards compatible: all v1.0 shortcodes, attributes, and theme functions preserved
  • New: uninstall.php — clean database removal on plugin delete

1.0

  • Initial release