Created
August 10, 2015 17:57
-
-
Save Fitoussi/69f2f4672929c09c900d to your computer and use it in GitHub Desktop.
Posts Locator Order-by Filter tutorial ( part 4 )
This file contains 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
function gmw_orderby_dropdown( $gmw ) { | |
//getting the chosen value so we could pre-select the selected value after page load | |
$selected = ( isset( $_GET['gmw_orderby' ) && !empty( $_GET['gmw_orderby'] ) ) ? $_GET['gmw_orderby'] : ''; | |
?> | |
<select class="gmw-orderby-dropdown" name="gmw_orderby"> | |
<option value="distance" selected="selected">Distance</option> | |
<option value="post_title" <?php if ( $selected == 'post_title' ) echo 'selected="selected"'; ?>>Alphabetically</option> | |
<option value="post_date" <?php if ( $selected == 'post_date' ) echo 'selected="selected"'; ?>>Post Date</option> | |
<option value="post_id" <?php if ( $selected == 'post_id' ) echo 'selected="selected"'; ?>>Post ID</option> | |
<option value="random" <?php if ( $selected == 'random' ) echo 'selected="selected"'; ?>>Random</option> | |
</select> | |
<?php | |
} | |
add_action( 'gmw_search_form_before_distance', 'gmw_orderby_dropdown', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment