Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul class="products">
- <?php
- global $post;
- // Setup your custom query
- $args = array('posts_per_page' => 4,'post_type' => 'product',
- //add category
- 'tax_query' => array(
- 'relation' => 'AND',
- array(
- 'taxonomy' => 'product_cat',
- 'field' => 'slug',
- 'terms' => 'html' //example : ‘term’ => ‘red-shoes’, ‘books’, ‘fiction-books’.
- )
- ),
- 'orderby' => 'title',
- );
- $myposts = get_posts( $args );
- foreach( $myposts as $post ) : setup_postdata($post); ?>
- <li class="col-sm-4">
- <div class="shop_product_inner"> <!-- shop_single here woocommerce img id you can ise usr won crop id -->
- <a href="<?php the_permalink() ?>">
- <?php if ( has_post_thumbnail( get_the_ID() ) ) {
- the_post_thumbnail('shop_single', array('class' => 'img-responsive project-image'));
- } else {
- echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" />';
- } ?>
- <div class="shop_product_inner_caption">
- <h2><?php the_title(); ?></h2>
- <p><?php echo $product->get_price_html(); ?></p>
- <?php woocommerce_template_loop_add_to_cart(); //ouptput the woocommerce loop add to cart button ?>
- </div>
- </a>
- </div>
- </li>
- <?php endforeach; ?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement