Random Products Snipped HELP
-
him need someone to help with a snipped. Im using the snipped below, to randomply show woocommerce products on every visit. so when someone visits the site, woocommerce shop products will randomly showed.
i want this ti aply only to the SHOP page and EXCLUDE the Main-Website Page. how can i modify the code to achive that? any idea?
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); function custom_woocommerce_get_catalog_ordering_args( $args ) { $orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); if(is_product_category('Alle Produkte - neue zuerst')){ $args['orderby'] = 'date'; $args['order'] = 'desc'; $args['meta_key'] = ''; } else if ( 'random_list' == $orderby_value ) { $args['orderby'] = 'rand'; $args['order'] = ''; $args['meta_key'] = ''; } return $args; } add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' ); add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' ); function custom_woocommerce_catalog_orderby( $sortby ) { $sortby['random_list'] = 'Zuf?llig'; return $sortby; }
The page I need help with: [log in to see the link]
- The topic ‘Random Products Snipped HELP’ is closed to new replies.