BuddyBoss Home – Web › Support Forums › Solutions › Social MarketPlace › add page identifier (body class) for product seller
- This topic has 4 replies, 2 contibutors, and was last updated 8 years, 7 months ago by Aaron.
Question
March 15, 2016 at 11:02 pm #63184@aaronkineI would like to style each Product page differently (using CSS) depending on who the Store Seller is. What php / hook / filter etc… can i use to add a specific CLASS to the Body tag (or anywhere else) that would allow me to use CSS and style every product page differently depending on who the Seller is (Vendor / Shop Owner)?
For now I am just thinking about stylizing the Product TITLE a certain color depending on who the Seller is.
Answers
March 16, 2016 at 1:58 am #63206@
AnonymousHi Aaron
Here is code that will add two class in form bm-vendor-“user id” to products:
add_filter( ‘body_class’, ‘bb_add_class’);
function bb_add_class($classes){
if(is_product()){
global $product;
$vendor_id = WCV_Vendors::get_vendor_from_product( $product->post->ID );
$classes[] = ‘bm-vendor-‘. $vendor_id;
}
return $classes;
}Regards
March 16, 2016 at 2:11 am #63209@
AnonymousHi Aaron
Forgot to tell you. Add this code to functions.php file of child theme.
March 16, 2016 at 10:11 am #63365@aaronkineThis is GREAT!! just what i needed. Thanks!
March 30, 2016 at 1:22 am #65964@aaronkineHello again… that code worked great. but now i need similar code to add a class to other pages for a specific Vendor on our site…. Let me explain what i need to accomplish…
This is our MAIN Featured Vendor (which will not change) “Art From Scrap”. And so throughout our site we need to be able to style them differently and also make their Store and Products FIRST Listed.
Their Vendor Page is here —> http://goodcommunities.loastage.com/vendors/art-from-scrap/
• We need to Add a Body Class (<body class=”bm-vendor-2″) on that page also. “similar to the code you already provided”… but your code only works on the Products pages. We need to add class to this Vendor throughout the site so we can style them differently.• Another example: our testing site home page is here…. http://goodcommunities.loastage.com/
we would like the (Art From Scrap) Vendor to Stay at the top (no matter what the Sort method is “Most Active, Alphabetical, Most Recent”) and also be styled differently as mentioned above
…..Currently on the home page there are only 2 vendors on our site and both are wrapped in the same Div and Class:
<article class=”table store-item” style=”opacity: 1;”></article> <— we need this one (Art From Scrap) to have its own Class so we can style it.
<article class=”table store-item” style=”opacity: 1;”></article>Thanks for any Links or help on this.
- The question ‘add page identifier (body class) for product seller’ is closed to new replies.