The implementation can be purely CSS, and depends on your specific HTML markup. However, the class you’ll need to target is supplied by the post_class()
template tag.
Let’s say you have something like the following, basic markup:
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-title">
<img ... />
<h1><?php the_title(); ?></h1>
</div>
<!-- Etc. -->
</div>
The post_class()
template tag will output a category-based class, category-{name}
, and also, category-{id}
. So, you can target either one in your stylesheet:
.category-{name} .post-title img {}
or
.category-{id} .post-title img {}
It’ll be specific to your markup, of course; but hopefully you get the idea.
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Display random categories on the front page (Finding and Editing Theme Functions)
- Remove “Parent” Selection When Adding/Editing Categories?
- How to show in search results posts with a particular tag in a particular category?
- Display thumbnails for certain category posts
- Random Featured Image Based on Category
- Show posts from all categories
- If it is a top level category show children otherwise show sibling categories
- How to display the category featured images [closed]
- Can I set a default featured image for a category?
- Using classes instead of global functions in functions.php
- Function to return true if current page has child pages
- Gutenberg editor add a custom category as wrapper for custom blocks
- Get rid of WordPress category, tag and author archives?
- Change admin bar to default:off
- List of all theme customizer control types?
- How can I hide a category from Contributors in the edit/add new post screen?
- WordPress Multiple Category Search
- How to remove categories filter from wordpress admin?
- How can I add the featured image functionality to a custom taxonomy?
- Decreasing the Memory Consumption of a WordPress Site?
- How can I make post fields required in WordPress?
- Check if current category has subcategories
- wp_nav_menu not appearing for a couple pages
- How to add the category ID to admin page
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- When to use esc_url, esc_html, esc_attr, and friends?
- How can I select a primary category?
- how to use a different domain/subdomain for authors/catagories on single site?
- wp_update_nav_menu_item() to insert categories
- Deleting default category in wordpress
- Delete a specific category when deleting a user
- How to get the url to tag & category base set by the user?
- How to list child categories in custom category template?
- How to create a widgetized sidebar for every category dynamically?
- How to change post thumbnail title and alt attributes to post title?
- Trash bin for categories
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- How to set up sub-categories for author pages?
- View category in the preview of Theme Customizer
- Only show category to certain user levels without plugin
- How to add a background image to category and display image on category page
- One WordPress Install, Two Categories. Each Category Gets a Domain
- Block multiple categories from Blog
- List Categories of the Parent Category of the Current Category
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- How to have a static category/author page?
- Create single.php for specific category by category id
- Show posts of one category only with Custom Taxonomy on single.php
- Save metabox checkboxes values to custom content type
- How to add a rel attribute to images that contains their categories?
- Select category in custom query
- exclude category from WordPress Form function
- wp_list_categories, Add class to all list items with children
- How to add custom template tag in wordpress theme?
- is_archive() content being shown instead of is_category()
- Check is category parent or not from its ID
- Order Taxonomy Term by date created
- Delete Post From Front-End and attachment permanently
- Apply custom category template to subcategories
- Hide post meta data on a specific category
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Format Brand value in Category view [closed]
- Add custom taxonomy under the category title
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- What is the advantage of using header-catname.php over is_category(‘catname’);?
- If category is in parent category?
- Remove ‘rel’ attributes from the_category() output
- Retrieve all posts within tag OR category?
- Edit the markup of categories list
- Multiple menu items highlighted
- Override the filter from plugin in child theme
- How to call custom function from functions.php in site-wide template files?
- If in category to be inside of a function
- in_category() works in single.php but not in page.php?
- Use a wordpress page to display a certain category
- Display the featured image from the last post
- Different excerpt styles per category, but chronological
- Display child categories in WooCommerce
- How to view WordPress’ default category IDs?
- Rename Default Category (Uncategorized) Via a Function
- New Theme creation
- Need help to structure our a complex hierarchy
- Where can I find the declaration of `$_wp_theme_features`?
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Change single.php template based on parent category
- Custom field picture instead of post thumbnail on category page
- How To Display Category list from Portfolio post type plugin?
- Inserting categories as a hierarchical terms from frontend form
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- How to add a post with new Taxonomy without assigning to default category?
- Code to display category-specific single.php is overriding normal single.php, too
- Getting page/category content to show up in my custom page template
- Loop Through Categories in Custom Field
- How do you add Author and date Published on Category Pages?
- Lowest catagory link
- Own Custom Tags/Category page ( posts)
- Gettind 404 not found wen click the view button for a given category custom post type portfolio
- How to create default categories in new installs?