Support » Fixing WordPress » HELP! This is driving me nuts! WP_Query issue

  • dabonz413

    (@dabonz413)


    Note: This problem is the same when I modify this to simply fetch posts.

    I have the newest version of Woocommerce and WordPress as of the time I’m writing this post. I am attempting to update a plugin to fetch products (recent, best sellers, featured) and displays them in a slider.

    It currently works in Google Chrome, but not in Firefox or IE, which leads me to believe it’s some sort of syntax mistake, but I’m at a loss. Anyone know what’ wrong with this code?

    if($prod_type == "recent")
    {
      $loop = new WP_Query(array('post_type'	=> 'product','post__in'=>$prod_arr, 'posts_per_page' => 16));
    }
    
    else if($prod_type == "best")
    {
      $loop = new WP_Query(array('post_type'	=> 'product','post__in'=>$prod_arr, 'posts_per_page' => 24, 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num'));
    }
    
    else if($prod_type == "featured")
    {
      $f_query_args = array('post_type'	=> 'product','post__in'=>$prod_arr, 'posts_per_page' => 24);
      $f_query_args['meta_query'] = array();
      $f_query_args['meta_query'][] = array(
        'key' => '_featured',
        'value' => 'yes'
      );
    
      $loop = new WP_Query($f_query_args);
    }

    The way my products are setup right now, the first two should return 9 items (I only have 9 items setup).

    In Chrome, they work fine but in IE and Firefox, they return only 1 item! I’m at a loss here guys. If you have any ideas, let me know.

    Thanks in advance!

  • The topic ‘HELP! This is driving me nuts! WP_Query issue’ is closed to new replies.