Created
March 3, 2014 09:52
-
-
Save Clorith/9321698 to your computer and use it in GitHub Desktop.
Quick filtering concept
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$searcharg = array(); | |
global $searcharg; | |
add_action( 'init', 'check_form' ); | |
add_action( 'pre_get_posts', 'make_fancy_query' ); | |
function check_form() { | |
if ( isset( $_GET['Checkme'] ) ) { | |
global $searcharg; | |
$searcharg = $_GET['Checkme']; | |
} | |
} | |
function make_fancy_query( $query ) { | |
global $searcharg; | |
if ( $query->is_main_query() && ! empty( $searcharg ) ) { | |
$query->set(); | |
} | |
} | |
?> | |
<form action="" method="get"> | |
<input type="text" name="s"> | |
<input type="checkbox" name="Checkme" value="check1"> | |
<input type="checkbox" name="Checkme" value="check2"> | |
<input type="checkbox" name="Checkme" value="check3"> | |
<input type="submit" value="Search"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment