Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTIONS.php
- function footyboots_construct_filter_query() {
- if(isset($_GET['producent'])) {
- $producentGET1 = $_GET['producent'];
- $producentGET = true;
- } else {
- $producentGET = false;
- }
- if(isset($_GET['produkttype'])) {
- $produkttypeGET1 = $_GET['produkttype'];
- $produkttypeGET = true;
- } else {
- $produkttypeGET = false;
- }
- if(isset($_GET['farve'])) {
- $farveGET1 = $_GET['farve'];
- $farveGET = true;
- } else {
- $farveGET = false;
- }
- if(isset($_GET['knopkonfiguration'])) {
- $knopkonfigurationGET1 = $_GET['knopkonfiguration'];
- $knopkonfigurationGET = true;
- } else {
- $knopkonfigurationGET = false;
- }
- if(isset($_GET['tilbud'])) {
- $tilbudGET1 = $_GET['tilbud'];
- $tilbudGET = true;
- } else {
- $tilbudGET = false;
- }
- $argsFilter = array(
- 'post_type' => 'fodboldstoevle',
- 'showposts' => -1,
- 'meta_query' => array(
- ($producentGET) ? array('key' => 'footyboots_producent','value' => $producentGET1) : null,
- ($produkttypeGET) ? array('key' => 'footyboots_produkttype','value' => $produkttypeGET1) : null,
- ($farveGET) ? array('key' => 'footyboots_farve','value' => $farveGET1) : null,
- ($knopkonfigurationGET) ? array('key' => 'footyboots_knopkonfiguration','value' => $knopkonfigurationGET1) : null,
- ($tilbudGET) ? array('key' => 'footyboots_tilbud','value' => $tilbudGET1) : null,
- ),
- );
- print_r($argsFilter);
- return $argsFilter;
- }
- STOEVLEFILTER.php
- <?php
- /* Template Name: Fodboldstøvle filter */
- get_header();
- ?>
- <div class="container">
- <h1>Støvler</h1>
- <div class="row">
- <div class="col-md-3">
- <button class="filter-btn visible-xs visible-sm" data-toggle="collapse" data-target="#filter-md">Vis filter</button>
- <div id="filter-md" class="sidebar collapse.in">
- <form action="<?php the_permalink(); ?>" method="GET">
- <section>
- <b>Pris</b>
- <ul class="filter-checkboxes">
- <li><input type="checkbox" id="checkboxTilbud" name="tilbud[]" value="tilbud"><label for="checkboxTilbud"><span></span>Vis kun tilbudsvarer</label></li>
- </ul>
- </section>
- <section>
- <b>Mærke</b>
- <ul class="filter-checkboxes">
- <li><input type="checkbox" id="checkboxAdidas" name="producent[]" class="producent123" value= adidas"><label for="checkboxAdidas"><span></span>adidas</label></li>
- <li><input type="checkbox" id="checkboxNike" name="producent[]" class="producent123" value="Nike"><label for="checkboxNike"><span></span>Nike</label></li>
- <li><input type="checkbox" id="checkboxPuma" name="producent[]" class="producent123" value="Puma"><label for="checkboxPuma"><span></span>Puma</label></li>
- </ul>
- </section>
- <section>
- <b>Produkt type</b>
- <ul class="filter-checkboxes">
- <li><input type="checkbox" id="checkboxStoevler" name="produkttype[]" value="Fodboldstøvler"><label for="checkboxStoevler"><span></span>Fodboldstøvler</label></li>
- <li><input type="checkbox" id="checkboxIndendoers" name="produkttype[]" value="Indendørssko"><label for="checkboxIndendoers"><span></span>Indendørssko</label></li>
- <li><input type="checkbox" id="checkboxKunstgraes" name="produkttype[]" value="Kunstgræsstøvler"><label for="checkboxKunstgraes"><span></span>Kunstsgræsstøvler</label></li>
- <li><input type="checkbox" id="checkboxGrus" name="produkttype[]" value="Grusbanestøvler"><label for="checkboxGrus"><span></span>Grusbanestøvler</label></li>
- </ul>
- </section>
- <section>
- <b>Farve</b>
- <ul class="filter-checkboxes">
- <li><input type="checkbox" id="checkboxBlaa" name="farve[]" value="Blå"><label for="checkboxBlaa"><span></span>Blå</label></li>
- <li><input type="checkbox" id="checkboxBrun" name="farve[]" value="Brun"><label for="checkboxBrun"><span></span>Brun</label></li>
- <li><input type="checkbox" id="checkboxGraa" name="farve[]" value="Grå"><label for="checkboxGraa"><span></span>Grå</label></li>
- <li><input type="checkbox" id="checkboxGroen" name="farve[]" value="Grøn"><label for="checkboxGroen"><span></span>Grøn</label></li>
- <li><input type="checkbox" id="checkboxGul" name="farve[]" value="Gul"><label for="checkboxGul"><span></span>Gul</label></li>
- <li><input type="checkbox" id="checkboxGuld" name="farve[]" value="Guld"><label for="checkboxGuld"><span></span>Guld</label></li>
- <li><input type="checkbox" id="checkboxHvid" name="farve[]" value="Hvid"><label for="checkboxHvid"><span></span>Hvid</label></li>
- <li><input type="checkbox" id="checkboxLilla" name="farve[]" value="Lilla"><label for="checkboxLilla"><span></span>Lilla</label></li>
- <li><input type="checkbox" id="checkboxOrange" name="farve[]" value="Orange"><label for="checkboxOrange"><span></span>Orange</label></li>
- <li><input type="checkbox" id="checkboxRoed" name="farve[]" value="Rød"><label for="checkboxRoed"><span></span>Rød</label></li>
- <li><input type="checkbox" id="checkboxSort" name="farve[]" value="Sort"><label for="checkboxSort"><span></span>Sort</label></li>
- <li><input type="checkbox" id="checkboxSoelv" name="farve[]" value="Sølv"><label for="checkboxSoelv"><span></span>Sølv</label></li>
- </ul>
- </section>
- <section>
- <b>Knopkonfiguration</b>
- <ul class="filter-checkboxes">
- <li><input type="checkbox" id="checkboxAG" name="knopkonfiguration[]" value="AG"><label for="checkboxAG" data-toggle="tooltip" data-placement="right" title="Artificial Grass - Kunstgræs"><span></span>AG</label></li>
- <li><input type="checkbox" id="checkboxFG" name="knopkonfiguration[]" value="FG"><label for="checkboxFG" data-toggle="tooltip" data-placement="right" title="Firm Ground - Naturlige græsbaner"><span></span>FG</label></li>
- <li><input type="checkbox" id="checkboxHG" name="knopkonfiguration[]" value="HG"><label for="checkboxHG" data-toggle="tooltip" data-placement="right" title="Hard Ground - Grus & kunstgræs"><span></span>HG</label></li>
- <li><input type="checkbox" id="checkboxIC" name="knopkonfiguration[]" value="IC"><label for="checkboxIC" data-toggle="tooltip" data-placement="right" title="Indendørssko"><span></span>IC</label></li>
- <li><input type="checkbox" id="checkboxSG" name="knopkonfiguration[]" value="SG"><label for="checkboxSG" data-toggle="tooltip" data-placement="right" title="Soft Ground - Blød vandet jord, typisk jernknopper"><span></span>SG</label></li>
- <li><input type="checkbox" id="checkboxTF" name="knopkonfiguration[]" value="TF"><label for="checkboxTF" data-toggle="tooltip" data-placement="right" title="Artificial Grass - Kunstgræs"><span></span>TF</label></li>
- </ul>
- </section>
- <input class="filter-btn" type="submit" id="filter_submit_btn" value="Find støvle">
- </form>
- </div>
- </div>
- <div class="col-md-9">
- <div class="row products">
- <?php
- $filterQuery = new WP_Query(footyboots_construct_filter_query());
- if($filterQuery->have_posts()):
- while($filterQuery->have_posts() ): $filterQuery->the_post();?>
- <div class="col-md-3 col-sm-6">
- <div class="product-preview">
- <?php
- if(footyboots_check_tilbud(rwmb_meta('footyboots_tilbudprocent'))) { ?>
- <div class="tilbud">
- <?php
- echo '-' . rwmb_meta('footyboots_tilbudprocent') .'%';
- ?>
- </div>
- <?php
- }
- footyboots_return_first_image(rwmb_meta('footyboots_produktbilleder'));
- ?>
- <b><?php echo rwmb_meta('footyboots_producent'); ?></b>
- <small><?php echo rwmb_meta('footyboots_navn') .' '.footyboots_implode('/', rwmb_meta('footyboots_knopkonfiguration')) .' '. footyboots_implode('/', rwmb_meta('footyboots_farve')); ?></small>
- <div class="text-center">
- <a href="<?php echo the_permalink(); ?>" class="btn btn-danger "><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> DKK <?php echo rwmb_meta('footyboots_pris'); ?>,-</a>
- </div>
- </div>
- </div>
- <?php
- endwhile;
- else:
- ?>
- Ingen støvler matcher din søgning:(
- <?php
- endif;
- wp_reset_postdata();
- ?>
- </div>
- </div>
- </div>
- </div>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment