This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Lädt das kategoriebild als background-image; | |
// Speicherort: In einem Kategorie- / Archiv-Template, z.B. in der archiv-product.php; | |
// Quelle: http://stackoverflow.com/questions/22537600/woocommerce-with-wordpress-how-can-i-display-category-image; | |
<?php | |
if (is_product_category()) { | |
global $wp_query; | |
$cat = $wp_query->get_queried_object(); | |
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Lädt aktiven Term-Namen; | |
// Speicherort: in irgendeinem Archiv-Template, z.B. in der archive-product.php; | |
// Quelle: http://codex.wordpress.org | |
<?php | |
$term = $wp_query->queried_object; | |
echo '<h1>Produkte zur Kategorie '.$term->name.'</h1>'; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Lädt alles Infos des aktuellen abgefragten Objekts und zeigt sie an; | |
// Speicherort: in irgendeinem Template; | |
// Quelle: http://codex.wordpress.org/Function_Reference/get_queried_object | |
<?php | |
$queried_object = get_queried_object(); | |
var_dump( $queried_object ); | |
?> | |
// Alternative: einzelne Werte des queried objects ausgeben: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Prüft Zuordnung zu einer bestimmten Eltern-Produktkategorie und gibt die Kategoriebeschreibung der zugeordneten Kind-Kategorie aus | |
// Speicherort: In einem Template, z.B. in der content-single-product.php | |
// Quelle: http://wordpress.stackexchange.com/questions/178687/output-single-post-custom-taxonomy-child-terms | |
// Beispiel: Folgender Code ermittelt für ein Produkt die zugeordneten Child-Terms des Terms mit der ID 17 der Taxonomy 'product_cat' | |
// und gibt deren Term-description aus | |
// Produkt-Kategorie Reiseziele (ID = 17), Unterkategorie Italien --> Ist ein Produkt der Kategorie Italien zugeordnet, dann wir die Beschreibung | |
// von Italien ausgegeben | |
<?php | |
$child_terms = get_term_children(17, 'product_cat'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Prüft Zuordnung zu einer bestimmten Produktkategorie und gibt die entsprechende Produkt-Kategoriebeschreibung aus | |
// Speicherort: In einem Template, z.B. in der content-single-product.php | |
// Quelle: Wordpress-Codex | |
// Beispiel: Folgender Code prüft, ob ein Produkt der Produkt-Kategorie 'reiseziel-1' oder 'reiseziel-2' zugroednet ist und gibt dann die | |
// entsprechende Produk-Kategoriebeschreibung aus; 20 ist die ID der Kategorie 'reiseziel-1' und 21 ist die ID der Kategorie 'reiseziel-2' | |
// Für 'reiseziel-2' wurde beispielhaft Html und eine CSS-Klasse mit eingefügt (Zeile 11); | |
<?php if( has_term( 'reiseziel-1', 'product_cat' ) ) { | |
echo term_description('20','product_cat'); } | |
elseif ( has_term( 'reiseziel-2', 'product_cat' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Legt eigene Produkt-Tabs an, deren Inhalte mit Hilfe von Feldern des Plugins ACF editiert werden könnnen | |
// Speicherort: functions.php | |
// Quelle: http://docs.woothemes.com/document/editing-product-data-tabs/ | |
// Beispiel: Mit folgendem Code werden 4 Reiter (=Tabs) angelegt (Reiter Programm, Reiter Highlights, Reiter Unterkunft und Reiter Leistungen; | |
// die Inhalte der einzelnen Tabs können im Wordpress-Backend bequem über je einen eigenen Editor eingegeben werden. | |
// Hierfür wird für jeden Tab ein Feld (Feld-Tytp WYSIWYG-Editor) mit Hilfe des WordPress-Plugins Plugins ACF (=Advanced Custom Fields) erstellt. | |
// CREATE TABS | |
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' ); | |
function woo_new_product_tab( $tabs ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Gibt Term-Infos des aufgerufenen Produktes aus; | |
// Speicherort: in irgendeinem Template, z.B. single-product.php | |
// Quelle: http://pastebin.com/vHLkP79d | |
<?php print_r( get_the_terms( $product->id, 'product_cat' ) ); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Entfernt die Standard-WC-Contentwrappers und fügt eigene Wrappers hinzu; | |
// Speicherort: functions.php | |
// Quelle: http://docs.woothemes.com/document/third-party-custom-theme-compatibility | |
// Removing WC-Wrappers | |
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); | |
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); | |
// Add Own Wrappers | |
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beschreibung: Fügt einem Theme WooCommerce-Unterstützung hinzu; | |
// Speicherort: functions.php | |
// Quelle: http://docs.woothemes.com/document/third-party-custom-theme-compatibility | |
add_action( 'after_setup_theme', 'woocommerce_support' ); | |
function woocommerce_support() { | |
add_theme_support( 'woocommerce' ); | |
NewerOlder