I'm struggling to apply some filters to WP_User_Query, I have the following query, followed by some filters also shown, when I apply the filters they appear within the url structure, so /?gender=Male but I'm struggling to connect the filters to what is actually output, is there a simple method to take what I have and apply the filters to the array? thanks
<?php
$args = array(
'role' => 'talent',
'order' => 'DESC',
'orderby' => 'user_registered',
'meta_key' => 'position',
'number' => '15',
'meta_query'=> array (
array(
'key' => 'picture',
'value' => array(''),
'compare' => 'NOT IN'
),
array(
'key' => 'position',
'value' => $title
)
)
);
$wp_user_query = new WP_User_Query($args);
$authors = $wp_user_query->get_results();
if (!empty($authors))
{
foreach ($authors as $author)
{
?>
<?php include(locate_template('profile.php')); ?>
<?php } ?>
<?php } else { ?>
<?php } ?>
Filters
<form>
<strong>
Age
</strong>
<span>
<select name="age">
<?php
$orderby_options = array(
'10' => '10',
'20' => '20',
'30' => '30',
);
foreach( $orderby_options as $value => $label ) {
echo "<option ".selected( $_GET['age'], $value )." value='$value'>$label</option>";
}
?>
</select>
</span>
<strong>
Gender
</strong>
<span>
<select name="gender">
<?php
$orderby_options = array(
'All' => 'All',
'Male' => 'Male',
'Female' => 'Female',
);
foreach( $orderby_options as $value => $label ) {
echo "<option ".selected( $_GET['gender'], $value )." value='$value'>$label</option>";
}
?>
</span>
<input type='submit' value='Search'>
</form>