absint( $featured_carousel_number ), 'no_found_rows' => true, 'post_type' => 'post', 'suppress_filters' => false, 'meta_query' => array( array( 'key' => '_thumbnail_id' ), ), ); if ( absint( $featured_carousel_category ) > 0 ) { $qargs['cat'] = absint( $featured_carousel_category ); } // Fetch posts. $all_posts = get_posts( $qargs ); $items = array(); if ( ! empty( $all_posts ) ) { $cnt = 0; foreach ( $all_posts as $key => $post ) { if ( has_post_thumbnail( $post->ID ) ) { $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $items[ $cnt ]['images'] = $image_array; $items[ $cnt ]['title'] = $post->post_title; $items[ $cnt ]['url'] = get_permalink( $post->ID ); $cnt++; } } } if ( ! empty( $items ) ) { $input = $items; } break; case 'featured-product-category': $featured_carousel_product_category = best_commerce_get_option( 'featured_carousel_product_category' ); $meta_query = WC()->query->get_meta_query(); $tax_query = WC()->query->get_tax_query(); if ( absint( $featured_carousel_product_category ) > 0 ) { $tax_query[] = array( 'taxonomy' => 'product_cat', 'terms' => absint( $featured_carousel_product_category ), ); } $qargs = array( 'posts_per_page' => absint( $featured_carousel_number ), 'no_found_rows' => true, 'post_type' => 'product', 'suppress_filters' => false, 'meta_query' => $meta_query, 'tax_query' => $tax_query, ); // Fetch posts. $all_posts = get_posts( $qargs ); $items = array(); if ( ! empty( $all_posts ) ) { $cnt = 0; foreach ( $all_posts as $key => $post ) { if ( has_post_thumbnail( $post->ID ) ) { $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $items[ $cnt ]['images'] = $image_array; $items[ $cnt ]['title'] = $post->post_title; $items[ $cnt ]['url'] = get_permalink( $post->ID ); $product = wc_get_product( $post->ID ); $items[ $cnt ]['price'] = $product->get_price(); $cnt++; } } } if ( ! empty( $items ) ) { $input = $items; } break; } return $input; } endif;