Hello,
I bought the Pro version and I’m trying to add a search form on my website to filter stuff based on location and category. I used the shortcode event_search as php
echo do_shortcode("[udalosti_search filters='event_category,state']");
As you can see there’s udalosti_search instead of event_search. That’s because I needed to modify some english strings but the problem remains even if I would change udalosti_search to event_search. The problem is that if you select a cetegory and hit the search button, the URL changes to http://www..cz/u/udalost/ZKUSEBNI-NOVINKA/?eo_search.
Exactly that Zkusebni-novinka is a post and because of that the search doesn’t show results but shows the latest post instead. I thought I could fix it by editing the URL in the
<
form> but when I only put u/udalost/ there, hit search, it then changes to zkusebni-novinka again..
You can test it yourself here: http://udalosti.4elementsgroup.cz/u/udalost/
Can you help me please?
Marek Zelezny
Hi Marek,
There is a hidden field with page ID set to 71. That is the page the shortcode thinks its on, but that appears to be in correct. Page #71 is the one you land on, Whereas the page the search form is on (I think) is #76. The only reason why this would happen is if the global $post
object doesn’t match the page you’re currently on. I’m not sure where you’re calling do_shortcode(...)
, but that may be a factor (try using it as a shortcode in the page content instead). Otherwise it could be a plug-in/theme modifying the global $post
or creating a WP_Query()
instance without calling wp_reset_postdata()
.
If using it has a shortcode in the page content doesn’t work, I’d recommend you first disable all other plug-ins/themes to idenfity which (if any) are perhaps causing a problem, and we can go from there.
Stephen Harris
I found out that the search doesn’t want to work on the archive page but if I add it to a custom template page, then it would work. Thanks!
Marek Zelezny
Ah yes, it’s really intended for use within a page/post or other ‘content’ so it knows where to return users to. Using it in a template file may confuse it (a page template shouldn’t as there isn’t any ambiguity as to what page you’re on).
In the next update there’ll hopefully be a template function you can use to display a search bar in a template and have the results displayed in the events page.
Stephen Harris