Skip to content

Instantly share code, notes, and snippets.

@webonaut
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webonaut/042c9644b56958bc8df3 to your computer and use it in GitHub Desktop.
Save webonaut/042c9644b56958bc8df3 to your computer and use it in GitHub Desktop.
WooCommerce - Unterschiedliche Templates laden je nach Produkt-Kategorie
// Beschreibung: Lädt unterschiedliche Templates, je nach zugeordneter Produkt-Kategorie;
// Speicherort: single-product.php
// Quelle: http://pastebin.com/vHLkP79d
// Beispiel: Ist ein Produkt der Kategorie 'custom-1' zugeordnet, wird das Template 'content-custom-1' aufgerufen
if ( has_term( 'custom-1', 'product_cat' ) ) {
wc_get_template_part( 'content', 'custom-1' );
} elseif ( has_term( 'custom-2', 'product_cat' ) ) {
wc_get_template_part( 'content', 'single-product-custom-2' );
} else {
wc_get_template_part( 'content', 'single-product' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment