Skip to content

Instantly share code, notes, and snippets.

@JayWood
Created September 2, 2016 16:48
Show Gist options
  • Save JayWood/e3c5b49b534e66bf3c247052f16bca80 to your computer and use it in GitHub Desktop.
Save JayWood/e3c5b49b534e66bf3c247052f16bca80 to your computer and use it in GitHub Desktop.
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"
}
}
return $classes;
}
add_filter( 'post_class', 'fb_1398591523488596', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment