Zum Hauptinhalt springen
Blog & News

Aktuelles & Updates von
Joomla, Wordpress und Co.

News, HowTos und Tutorials rund um Webdesign, Webentwicklung, Webhosting und Digitalisierung.

Blog & News

WooCommerce Featured & Ähnliche Produkte ausblenden

18.07.2018 · 2 Min Lesezeit

WooCommerce bietet von Haus aus einige Produkt-Loops welche nur umständlich per Skript deaktiviert werden können. Dabei ist es zu empfehlen die Funktion per PHP zu deaktivieren und nicht nur per CSS (display:none;) die Elemente zu verstecken.

Eine davon ist die Liste der Favoriten auf der WooCommerce Shop Startseite. Diese Liste lässt sich per Eintrag in die functions.php entfernen:

 

Ähnliche Produkte in der Detail-Ansicht eines Produktes deaktivieren

/** Remove related products output **/
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
/** alternativ **/
add_filter('woocommerce_product_related_posts_query', '__return_empty_array', 100);

Die Featured-Produkts auf der Shop Homepage von WooCommerce deaktivieren.

/** Remove Message - No Products Found **/
remove_action( 'woocommerce_no_products_found', 'wc_no_products_found' );
/** Remove loop @ WooCommerce shop page only **/
add_action( 'pre_get_posts', 'bbloomer_remove_products_from_shop_page' );
function bbloomer_remove_products_from_shop_page( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$q->set( 'tax_query', array(array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'null' ),
'operator' => 'IN'
)));
}
remove_action( 'pre_get_posts', 'bbloomer_remove_products_from_shop_page' );
}

Getestet auf https://www.cb-computech.de/shop/

Zurück zur Übersicht