echo '<hr>'; } } } } } do_action('before_product_list', $archive_template, $multiple_settings); $product_list = '<div class="product-list responsive ' . product_list_class() . '">'; if (is_home_archive()) { $args = array('post_type' => 'al_product'); query_posts($args); $is_home = 1; } while (have_posts()) { the_post(); $product_list .= get_catalog_template($archive_template, $post); } if (isset($is_home)) { wp_reset_query(); } $product_list .= '</div>'; $product_list = apply_filters('product_list_ready', $product_list, $archive_template); echo $product_list; ?> <span class="clear"></span> </div> </article> <?php product_archive_pagination();
function show_products_outside_loop($atts) { global $shortcode_query, $product_sort, $archive_template, $shortcode_args; $available_args = apply_filters('show_products_shortcode_args', array('post_type' => 'al_product', 'category' => '', 'product' => '', 'exclude' => '', 'products_limit' => -1, 'archive_template' => get_product_listing_template(), 'design_scheme' => '', 'sort' => 0, 'orderby' => '', 'order' => '', 'pagination' => 0)); $args = shortcode_atts($available_args, $atts); $shortcode_args = $args; $category = esc_html($args['category']); $product = esc_html($args['product']); $exclude = esc_html($args['exclude']); $products_limit = intval($args['products_limit']); $archive_template = esc_attr($args['archive_template']); $design_scheme = esc_attr($args['design_scheme']); $product_sort = intval($args['sort']); if ($product != 0) { $product_array = explode(',', $product); $query_param = array('post_type' => 'al_product', 'post__in' => $product_array, 'posts_per_page' => $products_limit); } else { if (!empty($category)) { $category_array = explode(',', $category); $field = 'name'; if (is_numeric($category_array[0])) { $field = 'term_id'; } $query_param = array('post_type' => 'al_product', 'tax_query' => array(array('taxonomy' => 'al_product-cat', 'field' => $field, 'terms' => $category_array)), 'posts_per_page' => $products_limit); } else { $query_param = array('post_type' => 'al_product', 'posts_per_page' => $products_limit); if (!empty($exclude)) { $query_param['post__not_in'] = explode(',', $exclude); } } } if (!empty($args['orderby'])) { $query_param['orderby'] = esc_attr($args['orderby']); } if (!empty($args['order'])) { $query_param['order'] = esc_attr($args['order']); } if (!empty($args['pagination'])) { $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1; $query_param['paged'] = $paged; } $query_param = apply_filters('shortcode_query', $query_param, $args); $shortcode_query = new WP_Query($query_param); $inside = ''; $i = 0; ob_start(); do_action('before_product_list', $archive_template); $before = ob_get_contents(); ob_end_clean(); while ($shortcode_query->have_posts()) { $shortcode_query->the_post(); global $post; $i++; $inside .= get_catalog_template($archive_template, $post, $i, $design_scheme); } $pagination = ''; if (!empty($args['pagination'])) { ob_start(); product_archive_pagination($shortcode_query); $pagination = ob_get_clean(); } $inside = apply_filters('product_list_ready', $inside, $archive_template, $args); wp_reset_postdata(); reset_row_class(); unset($shortcode_args); return $before . '<div class="product-list responsive ' . $archive_template . ' ' . product_list_class($archive_template) . '">' . $inside . '<div style="clear:both"></div>' . $pagination . '</div>'; }