I’ve built a recent item slider for the front page of my site, but now I’m trying to add a similar slider to a blog page that only gets the products from certain product tags.
Here is the code I have now that isn’t working. It displays all products, no matter the product tag.
$args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12,’product_tag’ => ’16’ );
I’ve also tried;
‘cat’ => ’16’
‘product_cat’ => ‘shoes’
‘product_cat’ => ’16’
‘product_tag’ => ‘shoes’
‘slug’ => ‘shoes’
Does anybody have any suggestions? I’m completely stuck on this issue!
‘product_tag’ and then the slug should work, if not try tax_query – I know for a fact that works because we use it in the related products queries.
That finally got it to work, but for some reason it displays 3 of the same product in my slider.
I’m not sure if my problems are in the database because I tried wp-ecommerce and jigoshop before switching to woocommerce.
Does that sound like a thing that could happen?
Is there an easy way to delete all other e-commerce data from the database, without removing all of my post/page data?
Could be that you have duplicates somewhere, somehow. Add post_status publish to your query, in case its pulling drafts/trashed products.
Didn’t seem to do anything. I’m guessing there is a jquery problem somewhere (it is an infinity slider, so it might want to duplicate it instead of going back to the first product)
I’ve put this issue to the side because my category thumbnails won’t display at all. It defaults to the placeholder.png file.
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, ‘shop_catalog’); else echo ‘<img src=”‘.$woocommerce->plugin_url().’/assets/images/placeholder.png” alt=”Placeholder” width=”‘.$woocommerce->get_image_size(‘shop_catalog_image_width’).’px” height=”‘.$woocommerce->get_image_size(‘shop_catalog_image_height’).’px” />’; ?>
I’ve tried substituting out ‘shop_catalog’ with ‘thumbnail’ and ‘large’ also. While messing around and re-uploading backup files, my category descriptions don’t display now either and I can’t remember where to edit that.
It’s gonna be a long night.
Slider issue sorted out. Apparently if i have less than 4 products in my slider (which is how many it displays at a time) it tries to fill up the space with duplicates.
Still can’t figure out the product category page thumbnail/excerpt issue or what file to edit to even begin.
Thumbnail code looks fine, maybe its this:
Note: To enable Post Thumbnails, the current theme must include add_theme_support( ‘post-thumbnails’ ); in its functions.php file. See also Post Thumbnails.
Thumbnails are working for everything else, it just won’t work when I set an image to my product categories.
Could you post the code for getting a product by tags?
I want to do the opposite and this was the only place that came close to answering my question (only backwards).
Here’s what I’m trying to do:
<?php $tags = wp_get_post_tags( $post->ID ); if ( $tags ): foreach ( $tags as $tag ): ?> <a href="<?php echo get_tag_link( $tag->term_id ); ?>"> <?php echo $tag->name; ?> </a> <?php endforeach; endif; ?>
@dustylavender : i super interested by the part of the code to “filter” out the product… you told it work but never post the code… can you post it here or PM me for that
i need to show only the woo commerce product that is 16 or shoe …
'cat' => '16' 'product_cat' => 'shoes' 'product_cat' => '16' 'product_tag' => 'shoes' 'slug' => 'shoes'
- The topic ‘[Plugin: Woocommerce] Filtering products by product tag problems’ is closed to new replies.