Posts

Showing posts from August, 2017

specific category product exclude in shop page woocommerce in wordpress

function custom_pre_get_posts_query( $q ) {     $tax_query = (array) $q->get( 'tax_query' );     $tax_query[] = array(            'taxonomy' => 'product_cat',            'field' => 'slug',            'terms' => array( 'diamond' ), // Don't display products in the clothing category on the shop page.            'operator' => 'NOT IN'     );     $q->set( 'tax_query', $tax_query ); } add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

Only specific category product show on shop page woocommerce wordpress

add_action('pre_get_posts','shop_filter_cat');  function shop_filter_cat($query) {     if (!is_admin() && is_post_type_archive( 'product' ) && $query->is_main_query()) {        $query->set('tax_query', array(                     array ('taxonomy' => 'product_cat',                                        'field' => 'slug',                                         'terms' => 'ring'          ...

WooCommerce - How to create multiple single product template based on category?

/* Diamond Category  */ add_filter( 'template_include', 'so_25789472_template_include' ); function so_25789472_template_include( $template ) {   if ( is_singular('product') && (has_term( 'diamond', 'product_cat')) ) {     $template = get_stylesheet_directory() . '/woocommerce/single-product- diamond.php';   }    return $template; } Reference Site: https://stackoverflow.com/questions/25789472/woocommerce-how-to-create-multiple-single-product-template-based-on-category  

Using PHP loop to add Bootstrap rows and proper column numbers to elements in wordpress post

    <?php if ( have_posts() ) : ?>                     <?php                 $i=0;                   while ( have_posts() ) : the_post(); ?>                                     <?php if ($i%4==0) {  ?>     <div class="row">     <?php } ?>                                                              <div class="col-m...