wordpress form filtering help
-
Im trying to use a form to filter my posts by some custom fields.
The issue at the moment is that its only using the last filter query and ignoring the first two.I havent done php for a year or two so I’ve forgotten everything.
Any tips as to what I’m doing wrong, and if there is a better way to go about it, please let me know.If there is a plugin that would be suited to solved this issue please let me know. I intended to use, WP-Smart-Sort-Premium, but its creator has gone awol and its no longer for sale…
Thank you.
<?php /* Template Name: Events v2.0 */ ?> <?php //Filter links ?> <form action="" method="post"> <input name="platform" value="Xbox 360" type="checkbox" id="commfees">Xbox 360 <br /> <input name="platform" value="PC" type="checkbox" id="commfees">PC <br /> <input name="game" value="Halo 3" type="checkbox" id="commfees">Halo 3 <br /> <input name="game" value="Modern Warfare 2" type="checkbox" id="commfees">Modern Warfare 2 <br /> <input name="prize" value=">=0" type="checkbox" id="commfees">$0 Prize <br /> <input name="prize" value=">=1" type="checkbox" id="commfees">$1+ Prize <br /> <input name="prize" value=">=1000" type="checkbox" id="commfees">$1000+ Prize <br /> <input type="submit" value="Submit" /> </form> <?php //setting filter values //platform if(isset($_POST['platform'])) { $var = $_POST['platform']; $platform = 'meta_key=Platform&meta_value='.$var.''; } else { $platform = 'meta_key=Platform'; } //Game if(isset($_POST['game'])) { $var = $_POST['game']; $game = 'meta_key=Game&meta_value='.$var.''; } else { $game = 'meta_key=Game'; } //Prize if(isset($_POST['prize'])) { $var = $_POST['prize']; $prize = 'meta_key=TotalPrizeValue&meta_value'.$var.''; } else { $prize = 'meta_key=TotalPrizeValue'; } ?> <?php //query string $query = $platform .'&'. $game .'&'. $prize; query_posts($query); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wordpress form filtering help’ is closed to new replies.