Tagged: slider, woocommerce
-
AuthorPosts
-
July 6, 2017 at 1:07 pm #817220
Hello people, any clue how to achieve to modify the product slider (woocommerce) to show products by attribute?
With the shortcode of woocommerce i can show them in grid view…. [product_attribute attribute=’color’ filter=’red’]
Thanks
July 7, 2017 at 2:37 pm #817851Hey webvigo,
Could you please give us a link to your website, we need more context to be able to help you.
Best regards,
VictoriaJuly 9, 2017 at 10:46 pm #818479Hello Victoria,
Yes let me provide you the demo page were i am working, thanks. I put the titles where i am using the directly shortcode of woocommerce that shows products by attributes and after, a block using the component of the theme “Products slider” that only allows us to show products by categories.
July 10, 2017 at 3:13 pm #818788Hi webvigo,
You need to modify the product slider query. Here is an idea on how to do it
https://kriesi.at/support/topic/featured-products-in-product-slider-home-page/#post-566482If you need further assistance please let us know.
Best regards,
VictoriaJuly 10, 2017 at 3:13 pm #818789Hi webvigo,
You need to modify the product slider query. Here is an idea on how to do it
https://kriesi.at/support/topic/featured-products-in-product-slider-home-page/#post-566482If you need further assistance please let us know.
Best regards,
VictoriaJuly 10, 2017 at 3:28 pm #818804Thanks, i will try to work on that.
July 10, 2017 at 5:03 pm #818870Thanks, it worked! I made the trick of using post_per_page to select the different attributes. I share my code for any other user:
add_action( 'pre_get_posts', 'pre_get_posts_featured', 10); function pre_get_posts_featured( $query ) { $vars = $query->query_vars; if($query->is_archive && $query->is_post_type_archive) { //var_dump($query); if( isset($vars['post_type']) && 'product' == $vars['post_type'] && $vars['posts_per_page'] >= '50') { if ($vars['posts_per_page'] == "50") { $attribute = "red"; } if ($vars['posts_per_page'] == "51") { $attribute = "blue"; } $taxquery = array( array( 'taxonomy' => 'pa_color', 'field' => 'slug', 'terms' => $attribute, 'compare' => '=' ) ); $query->set( 'tax_query', $taxquery ); } } return $query; }
July 10, 2017 at 6:00 pm #818899Victoria, any chance to do something similar with the related products in the single product view of woocommerce?
July 10, 2017 at 6:57 pm #818937Hi webvigo,
Great job! And thank you for sharing!
Here is something for you
https://github.com/woocommerce/woocommerce/issues/850
You can use the filter from this thread:If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.