-
-
Save MortenAndersen/2cda4918ef1b9db7f12e to your computer and use it in GitHub Desktop.
Revisions
-
MortenAndersen revised this gist
Sep 25, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,9 +9,9 @@ function woocommerce_product_tag( $atts ){ if ( empty( $atts ) ) return; extract( shortcode_atts( array( 'per_page' => '4', 'columns' => '4', 'orderby' => 'rand', 'order' => 'desc', 'tag' => '' ), $atts ) ); -
ChromeOrange revised this gist
Apr 3, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function woocommerce_product_tag( $atts ){ 'tag' => '' ), $atts ) ); if ( ! $tag ) return; // Default ordering args $ordering_args = $woocommerce->query->get_catalog_ordering_args( $orderby, $order ); -
ChromeOrange revised this gist
Mar 31, 2013 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ /** * List products in a product tag shortcode * Useage : [product_tag tag="foo"] */ add_shortcode( 'product_tag', 'woocommerce_product_tag' ); function woocommerce_product_tag( $atts ){ global $woocommerce, $woocommerce_loop; @@ -11,8 +11,8 @@ function woocommerce_product_tag( $atts ){ extract( shortcode_atts( array( 'per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'desc', 'tag' => '' ), $atts ) ); @@ -22,11 +22,11 @@ function woocommerce_product_tag( $atts ){ $ordering_args = $woocommerce->query->get_catalog_ordering_args( $orderby, $order ); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $ordering_args['orderby'], 'order' => $ordering_args['order'], 'posts_per_page' => $per_page, 'meta_query' => array( array( @@ -38,9 +38,9 @@ function woocommerce_product_tag( $atts ){ 'tax_query' => array( array( 'taxonomy' => 'product_tag', 'terms' => array( esc_attr($tag) ), 'field' => 'slug', 'operator' => 'IN' ) ) ); -
ChromeOrange created this gist
Mar 31, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,75 @@ /** * List products in a product tag shortcode * Useage : [product_tag tag="foo"] */ add_shortcode( 'product_tag', 'woocommerce_product_tag' ); function woocommerce_product_tag( $atts ){ global $woocommerce, $woocommerce_loop; if ( empty( $atts ) ) return; extract( shortcode_atts( array( 'per_page' => '12', 'columns' => '4', 'orderby' => 'title', 'order' => 'desc', 'tag' => '' ), $atts ) ); if ( ! $category ) return; // Default ordering args $ordering_args = $woocommerce->query->get_catalog_ordering_args( $orderby, $order ); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $ordering_args['orderby'], 'order' => $ordering_args['order'], 'posts_per_page' => $per_page, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ), 'tax_query' => array( array( 'taxonomy' => 'product_tag', 'terms' => array( esc_attr($tag) ), 'field' => 'slug', 'operator' => 'IN' ) ) ); if ( isset( $ordering_args['meta_key'] ) ) { $args['meta_key'] = $ordering_args['meta_key']; } ob_start(); $products = new WP_Query( $args ); $woocommerce_loop['columns'] = $columns; if ( $products->have_posts() ) : ?> <?php woocommerce_product_loop_start(); ?> <?php while ( $products->have_posts() ) : $products->the_post(); ?> <?php woocommerce_get_template_part( 'content', 'product' ); ?> <?php endwhile; // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> <?php endif; wp_reset_postdata(); return '<div class="woocommerce">' . ob_get_clean() . '</div>'; }