Change Shortcode wrapper in Woocommerce -


i'm using wordpress 3.8 + woocommerce 2.0 need change class of wrapper woocommerce generate when use shortcode.

i use shortcode: [recent_products per_page="12"] , output is:

<div class="woocommerce">    the_product_loop.... </div> 

i want obtain

<div class="mycustomclass">    the_product_loop.... </div> 

but can't find have change code... in class-wc-shortcodes.php file i've found declaration of function generates wrapper:

public static function shortcode_wrapper(     $function,     $atts    = array(),     $wrapper = array(         'class'  => 'woocommerce',         'before' => null,         'after'  => null     ) ) 

but... don't want change core files of woocommerce plugin, it's possible define custom class via functions.php??

you can create own shortcode, clone of default one, change, paste in functions.php:

function custom_recent_products_fx($atts) {     global $woocommerce_loop, $woocommerce;      extract(shortcode_atts(array(         'per_page'  => '12',         'columns'   => '4',         'orderby' => 'date',         'order' => 'desc'     ), $atts));      $meta_query = $woocommerce->query->get_meta_query();      $args = array(         'post_type' => 'product',         'post_status' => 'publish',         'ignore_sticky_posts'   => 1,         'posts_per_page' => $per_page,         'orderby' => $orderby,         'order' => $order,         'meta_query' => $meta_query     );      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 loop. ?>          <?php woocommerce_product_loop_end(); ?>      <?php endif;      wp_reset_postdata();      return '<div class="my_custom_class">' . ob_get_clean() . '</div>';  }  add_shortcode('custom_recent_products','custom_recent_products_fx'); 

notice @ end of function "my_custom_class", change needs.

this create new shortcode, same "recent_products" 1 change.

so output this, use on template:

 echo do_shortcode('[custom_recent_products per_page="3"]'); 

or in posts:

 [custom_recent_products per_page="3"] 

i don´t know if best approach, can see, class "woocommerce" returned directly on recent_products shortcode function html, can´t imagine how filter or hook anotherway.

hope helps , sorry bad english :)


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -