If the changes you need are strictly CSS, you can add the category names as classes to the body_class
via the body_class
filter.
add_filter('body_class','wpa76627_class_names');
function wpa76627_class_names( $classes ) {
if( is_singular( 'product' ) ):
global $post;
foreach( get_the_terms( $post->ID, 'product_cat' ) as $cat )
// maybe you want to make this more unique, like:
// $classes[] = 'product-category-' . $cat->slug;
$classes[] = $cat->slug;
endif;
return $classes;
}
This code checks if we are viewing a single product page, then loops over all product_cats, adding the slugs as classes to the body tag. This could also be adapted for any post type or taxonomy.
Related Posts:
- Different template of products for specific category. WooCommerce
- Woocommerce single product image blurred and small. Actual image is big
- Twenty Ten Theme: Replace the Logo by a picture without moving the code
- Changing appearance of WooCommerce product layout [closed]
- Stylesheet not being loaded? [closed]
- How to change background color in the Notepad++ text editor?
- Does WordPress work without a theme?
- Where can I sell WordPress themes and plugins? [closed]
- When cropping a header image, retain meta data (i.e. name, description, etc.) from original image?
- Difference between stylesheet_directory and template_directory
- Adding a Template to the Page Attributes Panel for both Posts and Pages?
- How do you change the theme location?
- Need to create a Theme demo site that features multiple themes
- How do I put my comment form above the comments?
- Edit theme wp_head
- Theme Advanced Styles in Visual Editor and Paragraphs
- Want to have the Post editor remembering the last editing position
- disable active plugins for specific theme
- Enqueue different stylesheets using IE conditionals
- Should I use RIPS tool to test my themes and plugins?
- Make the css of the widget overwrite theme css
- Override parent theme translation on child theme
- Forbidden 403 error, permission to access, unable to read htaccess
- A way to sort WordPress themes? [closed]
- Theme of codinghorror.com
- How to add template to theme in WP
- How can I show more than 15 themes at a time in the admin menu?
- What is the WordPress Pinecone sitting on top of? [closed]
- Why are some of my thumbnails not being generated?
- Making menu link open in new tab?
- Create a dashboard-style site (not WordPress dashboard) – is there a theme? [closed]
- Help with WordPress Query
- Only Homepage not loading properly
- Are theme .php files stored in the database?
- Execute filter in theme as last
- Why style.css with ?ver=3.9.2 not updating as the one without ?ver=3.9.2?
- Inconsistent translation on a WP site
- Guidelines / restrictions about advertising /donate begging unside wordpress plugins or themes
- Updating my free theme delete all my changes [closed]
- Custom wordpress Theme and Plugin repository
- Do not show one specific widget on one specific page
- Website redesign – New theme – Help needed
- How can we hide the parent’s theme url at the child themes details on a multisite?
- Tips for managing code when developing a parent theme framework
- How can I show full text, not summary for the homepage and in categories?
- Create custom pages with a plugin
- Wp theme not working well as forgot to create child theme [closed]
- Theming global variables – initializing in index.php but using in header.pho
- Understanding the theme details in style.css
- WordPress TwentyTen Theme Incompatible with Theme Unit Test
- WordPress theme logo handling (Trying to use GIF as logo)
- Installing a theme on localhost, Ubuntu 16.04
- Unable to find translations in WordPress theme
- How I update WordPress theme and plugins
- Methods for development wordpress themes [closed]
- Overwrite add_image_size defined by theme
- A thin line between native wordpress bahaviour and 3rd party themes
- Using filter in the widget causes fatal error
- is there a way to pass a parameter to a add_menu_page function?
- Will I lose the pages I’ve created within a default WordPress theme when adding a new theme?
- Theme title in admin shows full path [closed]
- Is there a way to see how a theme will look before buying it?
- Menu items do not “open” when mouse hover over them?
- In a specific blog, the K2 theme does not have a Text Widget
- Plugin Admin panel checkbox unchecked after submit
- admin-ajax.php 500 error when new users try to register
- How to push a theme update for a ciustom theme used on multiple independant self hosted sites?
- Removing a widget via theme editor
- theme customizations gone after enabling ssl
- Can’t embed certain youtube videos into theme
- How to customize a section of a widget only on certain pages or page
- How to fix blog article view and share #’s?
- How do I get the featured image to sit below the header in the twenty nineteen theme?
- Simple filter to change label name of Email Adress to something else
- I want add repository theme folder
- Basic wordpress search shows no results
- How do I remove search bar that isn’t a widget?
- Show only the beginning of post
- Changing theme folder name disrupts widgets
- WordPress Customazation API section in section
- How can I Update my Theme
- Use random theme
- Replacing current theme folder by previous version of the same folder produces “undefined function get_header()” error
- Theme comment callback results nothing
- Does not work bookmarklet in the theme Tagology
- How do I block a subdirectory from WordPress theming?
- Need Help Creating a Multi-Step, Video-Guided Enrollment Site
- Resetting Themes Folder to Default
- What is the general cut-off date for reviewed themes in the WordPress.org repository?
- Sub-Theme (based on Taxonomies)
- How to Hide Blog Post Author?
- How to work email subscribe in WordPress?
- Adding a wp_head hook from an included PHP file
- How to add a plugin in WordPress theme directory?
- Editing a theme
- Deleting Widgets in sidebar in Panthea theme
- Absolute and relative paths
- Am having issues intergrating this api into my wordpress site, any help please?
- Get header/footer list for a theme
- Help!!! Old theme doesn’t load scripts and conflitcs with plugins