Ben
Forum Replies Created
-
Forum: Plugins
In reply to: [GEO my WP] Listing results by category or taxonomyIt turned out to be a simple addition to the function above;
I replaced
$clauses['orderby'] = "pmeta.meta_value";
with
$clauses['orderby'] = "pmeta.meta_value, distance";
If you need to control the sort order you can do something like this:
$clauses['orderby'] = "pmeta.meta_value DESC, distance ASC";
This works for my project, however it would be helpful to understand how to filter using additional meta-keys or categories/taxonomies as an alternative.
Forum: Plugins
In reply to: [GEO my WP] Listing results by category or taxonomyI have tried another approach;
The custom post type listed in my results include a custom meta-key (using the wp-types plugin) which is a dropdown select box. The dropdown has two options: Featured or Licensed. I found this code in another thread which allows me to filter results by this custom field:
function order_gmw_results($clauses, $gmwQuery) { global $wpdb; $clauses['join'] .= " LEFT JOIN {$wpdb->prefix}postmeta AS pmeta ON({$wpdb->prefix}posts.ID = pmeta.post_id AND pmeta.meta_key = 'wpcf-featured-or-licensed')"; $clauses['orderby'] = "pmeta.meta_value"; return $clauses; } add_filter('gmw_pt_location_query_clauses', 'order_gmw_results',10,2);
This works great, but is is possible to orderby multiple meta-keys so that the results are first sorted by my featured-or-licensed key, then by distance? As it works now the posts are jumbled by distance and appear to be sorted by publish date.
Any help to orderby multiple meta-keys would be very much appreciated!
Forum: Plugins
In reply to: [GEO my WP] Listing results by category or taxonomyAdding a little more detail to this question…
I guess what I’m trying to do is something similar to Google’s sponsored listings. So, when a user searches for a Teacher close to their postcode/city they are presented with the closest results, however with ‘sponsored’/’featured’ results first. Ideally, being able to not only style these ‘featured’ results differently but also using different layout from the template so I can add more detail.
I have looked at the function for filtering results using a dropdown but I need this to run prior to the results being listed and showing all categories (that I have pre-selected).
Forum: Fixing WordPress
In reply to: search custom fieldsTo explain further on what I’m trying to do ………
I’m creating a Teacher’s Directory where every Teacher has their own post/page within State/Region categories, and parent categories of Country.
On those Country category pages I would like search forms where you can select a State/Region (from a dropdown list) and then Courses Available (from checkboxes). The Courses Available are custom fields and I would like the search function to find results that match ANY of the courses selected – not ALL. In other words, if a user selects Course 1 and Course 2, I would like search results displayed to include Teachers who only teach Course 1 and only teach Course 2.
If anyone has any suggestions on how I could go about this better than with the plugins above, it would be most welcome. ??
Forum: Plugins
In reply to: [Plugin: Flutter] Hide Flutter Write PanelsHey guys. Just thought I’d mention that I’ve switched from Flutter to Magic Fields too and have found the white-label-cms plugin to work in beautifully with it. Basically it lets you hide all the other less-used admin navigation links, so you can strip it right down to only Magic Fields showing – great for client’s websites.