Forums › Nearby Posts › Posts Locator Order-by Filter Tutorial
- This topic has 1 reply, 1 voice, and was last updated 6 years, 8 months ago by
bigint.
-
AuthorPosts
-
December 6, 2015 at 6:09 am #49364
bigint
MemberHi,
Thanks for the plug-in.
Does this tutorial post ‘Posts Locator Order-by Filter’ apply to the free plug-in please?
I have spent all day trying to get your below code to work by adding it to my child theme functions.php (not the GeoMyWP functions file).
1234567891011121314151617function 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 );Is the child theme functions where the above code should go please because I am just getting the below error?
Parse error: syntax error, unexpected ‘)’, expecting ‘]’ in D:\HostingSpaces\wwwroot\wp-content\themes\unite-child\functions.php on line 60
I am trying to get to be able to order the WooCommerce search results by price descriptions using value – price-desc. But, I just can’t get past the first part of the tutorial.
I am not a PHP developer, which I am sure is clear. I would really like to get this done because I can’t afford to pay anyone else to do it.
Thanks,
Daniel.
December 7, 2015 at 2:32 am #49368bigint
MemberHi,
I think that I have got the code from the tutorial working by combining the top code from the ‘order’ part of the tutorial instead of the code at the bottom of part 1, along with the ‘bottom’ code from the filter section.
Now I’ll have a go at sorting by price – fingers crossed.
Thanks anyway.
-
AuthorPosts
You must be logged in to reply to this topic.