Advertisement
tommyosheawebdesign

Show all woocommerce products

Dec 8th, 2018
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. /* Add Show All Products to Woocommerce Shortcode
  2. function woocommerce_shortcode_display_all_products($args)
  3. {
  4.  if(strtolower(@$args['post__in'][0])=='all')
  5.  {
  6.   global $wpdb;
  7.   $args['post__in'] = array();
  8.   $products = $wpdb->get_results("SELECT ID FROM ".$wpdb->posts." WHERE `post_type`='product'",ARRAY_A);
  9.   foreach($products as $k => $v) { $args['post__in'][] = $products[$k]['ID']; }
  10.  }
  11.  return $args;
  12. }
  13. add_filter('woocommerce_shortcode_products_query', 'woocommerce_shortcode_display_all_products');*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement