--- title: Display taxonomy terms as a card grid in WordPress description: The Query Loop block lists posts, not taxonomy terms. This small plugin adds a Gutenberg block that renders any taxonomy as a grid of clickable cards. source: https://steem.dev/blog/wordpress-taxonomy-card-grid-block published: 2026-09-12 updated: 2026-10-31 site: Steem — AI WordPress plugin generator --- # Display taxonomy terms as a card grid in WordPress Build a site with custom post types and you often want a page of top-level categories as cards: a projects page with a tile per project type, a services page where each area links to its archive, a recipe site with cuisines as the way in. Click a card, land on that term's archive. The Query Loop block cannot do it. It queries posts, and terms are a different data type in a different table, with no mode for looping over them. The workarounds are a PHP template, a shortcode, a page builder, or a widget that prints a flat list with no layout control. This plugin adds a Taxonomy Cards block. Pick a taxonomy, set the columns, and the block renders its top-level terms as cards linking to their archives. It is rendered on the server, takes its spacing from your theme, and adds nothing to your stylesheet. ## What one build covers - A server-side rendered Gutenberg block that displays any registered WordPress taxonomy as a card grid - Column control from one to four, with optional term description and post count per card - Top-level terms by default, with a parent term ID setting to display any term's direct children instead - Each card linked to the term archive URL, populated automatically from get_term_link - Automatic refresh: add or rename a term in the admin and it appears in the grid on the next page load ## What it does not cover - Custom images per term card; image support requires a follow-up prompt once the base block is working - WooCommerce product category featured images; the WooCommerce Products blocks handle that already - Pagination or lazy loading when a taxonomy has many terms - Interactive front-end filtering or keyword search across the term grid - Custom ordering beyond alphabetical and WordPress term order ## The prompt ```text Build a WordPress plugin that registers a server-side-rendered Gutenberg block named 'steem/taxonomy-cards' with title 'Taxonomy Cards'. Create a block.json at the plugin root with name 'steem/taxonomy-cards', title 'Taxonomy Cards', category 'widgets', editorScript 'file:./build/index.js', and attributes: taxonomy (type string, default 'category'), parent_term (type integer, default 0), columns (type integer, default 3), show_description (type boolean, default true), show_count (type boolean, default false). In the main PHP file register the block on the init hook using register_block_type pointing to the block.json file, with a render_callback. The render callback should call get_terms with args: taxonomy from attributes, parent from the parent_term attribute, hide_empty false, orderby 'name'. If the result is a WP_Error or empty array, return a p element with 'No terms found.' wrapped in the block wrapper. Otherwise build the output: a div with class 'wp-block-steem-taxonomy-cards' and inline style '--columns:[columns value]', and for each WP_Term an article with class 'taxonomy-card' containing: an h3 with an anchor whose href is get_term_link and text is esc_html of term name; if show_description is true and term description is not empty, a p with esc_html of term description; if show_count is true, a span with class 'taxonomy-card__count' containing esc_html of term count followed by ' posts'. Return the full output string. Add an inline style via wp_add_inline_style on 'wp-block-library' for: .wp-block-steem-taxonomy-cards { display:grid; grid-template-columns:repeat(var(--columns,3),1fr); gap:1.5em; } .taxonomy-card { border:1px solid #ddd; padding:1em; border-radius:4px; } .taxonomy-card h3 { margin:0 0 0.5em; } .taxonomy-card__count { font-size:0.875em; color:#666; }. Write a src/index.js. In index.js import registerBlockType from @wordpress/blocks; import InspectorControls and useBlockProps from @wordpress/block-editor; import PanelBody, SelectControl, TextControl, RangeControl, ToggleControl, Placeholder from @wordpress/components; import apiFetch from @wordpress/api-fetch; import useState and useEffect from @wordpress/element. Call registerBlockType with the block name, using metadata from block.json, and an edit function that: uses useState for taxonomyOptions initialised to empty array; uses useEffect to call apiFetch on /wp/v2/taxonomies and on success set taxonomyOptions to Object.values(response).map(t => ({ label: t.name, value: t.slug })); renders a div with useBlockProps containing an InspectorControls with a PanelBody labelled 'Block Settings' holding SelectControl for taxonomy, TextControl for Parent Term ID (type number, parsed to integer on onChange), RangeControl for Columns min 1 max 4, ToggleControl for Show Description, ToggleControl for Show Count; and a Placeholder label='Taxonomy Cards' with a p element reading 'Showing ' + attributes.taxonomy + ' terms as a ' + attributes.columns + '-column grid.'. The save function returns null. Add a package.json with scripts: { "build": "wp-scripts build" } and devDependencies for @wordpress/scripts. Register all PHP hooks inside a function attached to plugins_loaded. ``` ## Any taxonomy, the top level or one branch A dropdown in the block inspector lists every taxonomy registered on the site, so nothing needs typing: the built-in Category and Tag, custom taxonomies from your theme, or ones created with a plugin like ACF. By default it shows top-level terms, those with no parent. Put a term's ID in the Parent Term ID setting to show that term's direct children instead, which makes drill-down navigation possible: a top-level grid on one page, then a block on each parent's page listing its children. Leave it at 0 for the top level. Each card shows the term name as a heading linked to its archive via `get_term_link`, with optional toggles for the term description and its post count, and a column control from one to four. Each block on a page is independent, so two grids with different taxonomies, parents or column counts can sit side by side. ## Sites people browse by category It is for sites where visitors browse by topic rather than date: portfolios organised by project type or industry, learning sites where topics or skill levels are the main navigation, recipe sites with cuisines or dietary labels on the homepage. The block renders with PHP and `get_terms`, so it always shows current data. Add or rename a term in the admin and the grid reflects it on the next page load. Being server-rendered, it inherits your theme's layout. The column count is a CSS custom property on the wrapper, and the gap uses the theme's spacing scale where the theme provides one, so there is no plugin stylesheet to override. ## Term images, WooCommerce categories and live filtering There is no image per card beyond the description. Sites that need term images usually keep them in term meta, through something like Yoast SEO's category image field or a dedicated term meta box. A follow-up message can read an image ID from a term meta key (`thumbnail_id` by default) and show the image above each term name, with the name as its alt text. On a WooCommerce store showing product categories with their images, use the Product Categories block WooCommerce already ships, which has image support and more styling options. The grid is a static list. Filtering or sorting it on the page without a reload would need JavaScript and a different build. --- Source: https://steem.dev/blog/wordpress-taxonomy-card-grid-block Build this plugin: https://steem.dev/app