Title: Adding a &#8216;If Product Attribute is&#8217; CSS Code
Last modified: June 21, 2019

---

# Adding a ‘If Product Attribute is’ CSS Code

 *  [kanto19](https://wordpress.org/support/users/kanto19/)
 * (@kanto19)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/adding-a-if-product-attribute-is-css-code-2/)
 * Hey fellas, I’m trying to edit this code as so
 * If
    Product Attribute Scanned text is ‘Image is a stock photo’ Then do this code
 *     ```
       @media (min-width: 769px) {
       .woocommerce #content div.product div.images,
       .woocommerce div.product div.images,
       .woocommerce-page #content div.product div.images,
       .woocommerce-page div.product div.images {
       width: 30%;
       }
       .woocommerce #content div.product div.summary,
       .woocommerce div.product div.summary,
       .woocommerce-page #content div.product div.summary,
       .woocommerce-page div.product div.summary {
       float: right;
       width: 65%;
       }
       }
       ```
   
 * Any ideas on how I can implement this? It’s a fix I’ve found that works with 
   my website to specific listings.
 * Thank you.
    -  This topic was modified 6 years, 11 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
    -  This topic was modified 6 years, 11 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-a-if-product-attribute-is-css-code-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Anonymous User 17275278
 * (@anonymized-17275278)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/adding-a-if-product-attribute-is-css-code-2/#post-11663046)
 * What about something like this?
 *     ```
       function hook_css() {
        <?php
         $product_attribute = //get what you need here;
         if($product_attribute == "Image is a stock photo")
          echo '<link rel="stylesheet" type="text/css" href="yourcss.css">';
        ?>
       }
       add_action('wp_head', 'hook_css');
       ```
   
 * You can paste this into your function.php, don’t forget to pass your parameter
   to the variable.
 *  Thread Starter [kanto19](https://wordpress.org/support/users/kanto19/)
 * (@kanto19)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/adding-a-if-product-attribute-is-css-code-2/#post-11664294)
 * Could you give me a hand implementing it? I’m having some issues.
 * The fuction.php is not allowing me to save the code into it
 * Your PHP code changes were rolled back due to an error on line 27 of file wp-
   content/themes/themify-shoppe/functions.php. Please fix and try saving again.
 * syntax error, unexpected ‘<
 * Sorry, I have very limited knowledge on advanced coding.
 * Thank you for your time!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding a ‘If Product Attribute is’ CSS Code’ is closed to new replies.

## Tags

 * [css](https://wordpress.org/support/topic-tag/css/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [wp_head](https://wordpress.org/support/topic-tag/wp_head/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [kanto19](https://wordpress.org/support/users/kanto19/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/adding-a-if-product-attribute-is-css-code-2/#post-11664294)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
