I'm trying to order my posts by the nearest location to a user. To solve this issue I created a table called geolocation that contains all latitude(lat) and longditude(long) of by post_id. In order to sort the posts I used the following hook: woocommerce_get_catalog_ordering_args The issue I'm facing Is that I need to join the table I created so I can order the products by lat and long ( ORDER BY (POW((geodata.long-9.9533548),2) + POW((geodata.lat-49.7913044),2)) ASC ) Using various examples this is what I've came up with - however I'm receiving a 500 Internal error and I'm unsure how to get the join working so I can order by attributes in another table: add_filter( 'woocommerce_catalog_orderby', 'add_custom_sorting', 99999); function add_custom_sorting( $options) { $options['distance'] = 'Nach Standort sortieren'; return $options; } add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_sorting_f...
A site where you can share knowledge