Hi,
please note that this thread was related to the Maps and Locations extension (against the forum rules though), in order to be able to use the code i pasted there you would need to have the MAL extension https://wpadverts.com/extensions/maps-and-locations/ installed and configured.
Thread Starter
titusb
(@titusb)
I see, thank you!
So when I understand it right, there is no possibility without MAL to produce the same result that user get by entering a location in the search field through a specific location-defining shortcode?
Hi,
yes, this is possible only with the Maps and Locations extension only, sorry.
I mean, it is also possible to custom code something like that, but doing so (most likely) would be more expensive than getting the Pro package.
One other option would be to change the my_custom_shortcode_param function from the linked thread to
function my_custom_shortcode_param($args, $params) {
if(!empty($params["_location"])) {
$args["meta_query"][] = array(
'key'=>'adverts_location',
'value'=>$params["_location"],
'compare'=>'LIKE'
);
}
return $args;
}
Then use [adverts_list] as [adverts_list _location='my location'] where ‘my location’ is a part (or whole location) user entered in the Location field when posting an Ad.
For example, if you have an Ad with Location “New York” then using the shortcode as [adverts_list _location="York"] should show this Ad.
So this is possible without the MAL but will not be as accurate as when using the location taxonomy.
Thread Starter
titusb
(@titusb)
You are amazing, thank you Greg!
I think this is a really good point to start with! At the moment I’m totally fine with the disadvantages of this approach. In case people really start using our site we’ll step up to MAL I guess.
All the best!
Titus