Skip to content

Instantly share code, notes, and snippets.

View urbanoantunes's full-sized avatar

urbanoantunes

View GitHub Profile
function add_custom_classes( $classes, $class, $post_id ) {
if ( 'product' == get_post_type( $post_id ) ) {
$classes[] = "sm-pid-" . $post_id;
// Post Class on Single Product
if ( is_singular( 'product' ) ) {
$classes[] = "sm-product-view";
// Post Clas Product Archives Listing
} else {
@JayWood
JayWood / wcpc.php
Created September 2, 2016 16:48
Woocommerce Product Singular vs Archive classes
<?php
function fb_1398591523488596( $classes, $class, $post_id ) {
if ( 'product' == get_post_type( $post_id ) ) {
if ( is_singular( 'product' ) ) {
$classes[] = "post-class-when-viewing-single-product";
} else {
$classes[] = "non-single-product-page-class"
}
}
@JayWood
JayWood / product-class.php
Created August 31, 2016 19:33
Woocommerce Product Class
<?php
function fb_1398591523488596( $classes, $class, $post_id ) {
if ( 'product' == get_post_type( $post_id ) ) {
$classes[] = "my-amazing-product-class";
}
return $classes;
}