Repository navigation
Single post 'Category' element enabled but categories not displayed on single posts #310
Description
Summary
Single-post category labels (the colored category badges shown above a post) can be hidden on single posts even when the "Category" post element is enabled in the Single Post > Post Elements setting. The category element rendering (colormag_colored_category) depends on the wrong customizer setting for whether to show categories, causing categories not to appear on single post pages while tags do.
Customer context
Transcript: A user of the ColorMag theme reports that categories are missing from single posts on their site (https://www.contestscoop.com/) while tags are shown. They confirm the theme is ColorMag and that the category element is enabled in the customizer. Conversation source: Crisp session_320f7e5d-fdb6-4e8a-84ef-3c7b2d5a2ab3.
Reproduction notes
- In the Customizer, enable Post Content > Single Post > Post Elements > Categories.
- Ensure single post meta settings do not include categories (Single Post Meta Structure may be set to only date/author).
- Visit a single post. Categories do not display; tags may show if enabled.
I reproduced this by reading the theme code (see Diagnosis). I have not executed a runtime reproduction against a running WordPress instance in this environment.
Diagnosis
Root cause: The single-post category element rendering is gated by a different theme-mod than users would expect.
Relevant code paths:
- template-parts/content-single.php:102-105 — the single-post template iterates the single post element order and calls colormag_colored_category() when the 'category' element is present.
- inc/template-tags.php:260-300 — function colormag_colored_category() decides whether to output categories by checking the theme mod 'colormag_post_meta_structure' (variable $meta_structure = get_theme_mod('colormag_post_meta_structure', array('categories','date','author',...))). It only outputs categories if in_array('categories', $meta_structure).
- inc/template-tags.php:86-176 — function colormag_entry_meta() (used for post meta output) reads different theme mods for blog vs single post meta structure (e.g. 'colormag_single_post_meta_structure'), but it never renders categories (it supports 'date', 'author', 'views', 'comments', 'tags', etc.).
Effect: Enabling the Single Post > Post Elements > Categories control will call colormag_colored_category(), but whether categories actually render depends on the 'colormag_post_meta_structure' setting (likely intended for archive/blog posts) rather than the single-post meta structure. If a site owner removed categories from single-post meta structure or changed post-meta controls, categories will not appear despite the Single Post element being enabled.
Suggested fix: Use a single, consistent setting for whether categories appear on single posts. Specifically, colormag_colored_category() should check 'colormag_single_post_meta_structure' (the per-single-post meta setting) or a dedicated 'colormag_single_post_show_categories' flag rather than 'colormag_post_meta_structure'. Alternatively, ensure the customizer UI communicates that category badges are controlled by the "Post Meta Structure" setting (and include categories there) so users are not surprised.
Confidence: 85/100
Source: Crisp conversation
Activity
Fix - Category badge text unreadable when its color resolves to white