Codemetric Taxonomy Icons

By codemetric

0+ active installationsVersion 1.0.0

Assign an icon to each category or other taxonomy term, then display it with two blocks, two Elementor widgets or in your theme.

Description

Taxonomy Icons adds an icon picker to the term edit screen of categories and of any other public taxonomy. The icons come from the WordPress Icons registry, the same source as the core Icon block. You can also turn on extra icon sets.

Show the icons with the two included blocks, with the matching Elementor widgets, or with template functions in your theme. The plugin is compatible with Elementor.

Features

  • Icon selector on the term edit screen of each enabled taxonomy.
  • Settings page to choose which taxonomies support icons.
  • Optional extra icon sets: Phosphor, Tabler (filled and outline) and Material (filled and outline).
  • Categories with icons block: shows the terms of the current post, for any post type and any taxonomy chosen in the block settings. Works inside a Query Loop.
  • Categories list with icons block: lists all terms of a taxonomy, with options to show post counts, show only top-level terms, include empty terms and exclude specific terms.
  • Both blocks can show the icon, the name or both, with settings for icon width and icon color.
  • Supports color, typography, spacing and border settings.
  • Compatible with Elementor: both blocks are also available as Elementor widgets. They work in Elementor loop items.
  • Translation ready.

Template functions

codemcti_get_category_icon( $term = null, $args = array() )

Returns the SVG markup of the icon assigned to a term, or an empty string. $term is a term object or ID and defaults to the queried term. $args accepts size (pixels, default 24), class and label (an empty label marks the icon as decorative).

codemcti_the_category_icon( $term = null, $args = array() )

Prints the icon. Takes the same arguments.

codemcti_get_category_icon_name( $term = null )

Returns the registered icon name, for example core/star-filled.

Filters

  • codemcti_taxonomies: filters the taxonomies that support icons.
  • codemcti_available_icon_sets: filters the extra icon sets offered on the settings page.

Credits

  • Phosphor Icons: https://phosphoricons.com/ (MIT License)
  • Tabler Icons: https://tabler.io/icons (MIT License)
  • Material Symbols: https://fonts.google.com/icons (Apache License 2.0)

Installation

  1. Upload the codemetric-taxonomy-icons folder to /wp-content/plugins/, or install the plugin from the Plugins screen.
  2. Activate the plugin from the Plugins screen.
  3. Go to Settings > Taxonomy Icons to choose the taxonomies that support icons and turn on any extra icon sets.
  4. Edit a term (for example under Posts > Categories) and choose its icon.
  5. Add the Categories with icons or Categories list with icons block to a post, page or template.

FAQ

Which taxonomies are supported?

By default only Categories. You can turn on any other public taxonomy, including custom ones, on the settings page.

Can I use it with custom post types?

Yes. In the Categories with icons block, choose the taxonomy to show in the block settings panel. The list contains only the taxonomies registered for the current post type.

Is the plugin compatible with Elementor?

Yes. When Elementor is active, the Categories with icons and Categories list with icons widgets appear in the General category of the Elementor panel. They also work inside Elementor loop items.

Why does the block show nothing?

The block shows nothing when the post has no terms in the chosen taxonomy, or when the chosen taxonomy is not registered for the post type.

Why does the plugin require WordPress 7.1?

It relies on the WordPress Icons registry to store and render icons.

Screenshots

Changelog

1.0.0

  • Initial release.