Wordpress

WordPress get woocommerce featured products

WordPress get woocommerce featured products
  • lasantha

    Good article. we can use woocommerce shortcodes also
    eg. [featured_products per_page=”12″ columns=”4″]

    • Thanks for the reply macho.Yeah, then you can get each separate shortcode parameters/attributes and pass them into wordpress custom query and set the layout of the design.
      eg:

      function featured_products($atts){
      extract(shortcode_atts(array(
      ‘per_page’ => 1,
      ‘columns’ =>1
      ), $atts));

      $args = array(
      ‘post_type’ => ‘product’,
      ‘post_status’ => ‘publish’,
      ‘meta_key’ => ‘_featured’,
      ‘meta_value’ => ‘yes’,
      ‘posts_per_page’ => $per_page //parameter
      );

      …………………… etc

      Regards