<?php /** * The Template for displaying products in a product category. Simply includes the archive template * * This template can be overridden by copying it to yourtheme/woocommerce/taxonomy-product_cat.php. * * HOWEVER, on occasion WooCommerce will need to update template files and you * (the theme developer) will need to copy the new files to your theme to * maintain compatibility. We try to do this as little as possible, but it does * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * * @see https://docs.woocommerce.com/document/template-structure/ * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } // Register and enqueue live search script add_action('wp_enqueue_scripts', 'fivetwelve_live_search_script'); function fivetwelve_live_search_script() { wp_register_script( 'live-search', get_stylesheet_directory_uri() . '/js/live-search.js', array('jquery'), '1.0.0', false ); wp_enqueue_script( 'live-search' ); } // Add the live search inputs above the products add_action( 'woocommerce_before_shop_loop', 'fivetwelve_live_search' ); function fivetwelve_live_search() { ?> <div class="live-search-wrap"> <!-- These filtering fields can be hidden with CSS. They are populated via query strings in the URL, sent from the intake form. --> <form id="live-search" action="" class="styled" method="post"> <fieldset> <!-- Create an input field that looks for the "var1" query parameter in the URL --> <input type="text" class="text-input" id="filterVar1" value="<?php echo $_GET["var1"]; ?>" /> <!-- Display the returned count of elements matching var1 --> <span id="filter-count-var1"></span> <!-- Create an input field that looks for the "var2" query parameter in the URL --> <input type="text" class="text-input" id="filterVar2" value="<?php echo $_GET["var2"]; ?>" /> <!-- Display the returned count of elements matching var2 --> <span id="filter-count-var2"></span> </fieldset> </form> </div><!-- end .live-search-wrap --> <?php } wc_get_template( 'archive-product.php' );