/** * products result count in archive page */ function hwoo_archive_result_count() { $data = utility_data(func_get_args()); global $wp_query; if (!woocommerce_products_will_display()) { return; } $paged = max(1, $wp_query->get('paged')); $per_page = $wp_query->get('posts_per_page'); $total = $wp_query->found_posts; $first = $per_page * $paged - $per_page + 1; $last = min($total, $wp_query->get('posts_per_page') * $paged); $context = HW_Timber::load($data['current_working_template']); $context['total'] = $total; $context['first'] = $first; $context['last'] = $last; $context['show_all'] = $total <= $per_page || -1 == $per_page; HW_Timber::_render(array('woo/loop/result-count.twig'), $context); }
/** * @param $file * @return mixed */ public static function load($file) { self::$current_working_file = $file; //change current working template return Timber::get_context(); }
/** * @param $name */ public static function add_context($name) { HW_Timber::add_context($name, get_called_class()); }