Customizing Geodirectory Search Results Page and WordPress Search Results Page using Elementor Pro and jQuery – @pixallus

cropped-pixallus-web-devlopment.jpg

Geodirectory v2 comes packed with features. I’m especially glad they finally decided to shortcode everything. This gives us more control of the dynamic layouts when using a page builder like, Elementor Pro. Designing the Geodirectory Archives, Single Post, and Loop Items were fun tasks even if having to learn all of the changes Geodirecroty v2 offers. It’s definitely an improvement.

During upgrading to Geodirectory v2, I came across an issue with search results page. When creating a Search Results template and assigning it via Elementor Pro, I noticed that we lost the default WordPress search results page. I tried several methods to separate the search results pages, without luck.

I ended up creating a Search Page template in Elementor Pro that included both the default WordPress search results and the Geodirectory v2 search results. I set the Elementor conditions for the template to Search Results. Now when I search from either the Geodirectory search bar or the default WordPress search bar, I can see both results. However, this isn’t exactly what I wanted.

I want to display search results for one or the other depending on which search bar was used. So I added a class to each results section in the template and then added some jQuery to determine which class to display based on the URL. See the code below.

<script>
if (window.location.search.indexOf('search') > -1){
jQuery('.searchresults-gdclass1').css({"display":"block"});
jQuery('.searchresults-wpclass').css({"display":"none"});
} else {
jQuery('.searchresults-gdclass1').css({"display":"none"});
jQuery('.searchresults-wpclass').css({"display":"block"});
}
</script>

This probably isn’t the best way to handle this and I believe the Geodirectory is working on a fix. But for now, this will work for us. If you need help or guidance, please feel free to post in our support forums!

Share this page

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on email

Web Development Merit Badges

Changed a DNS record and everything worked just fine Comprehended someone else’s RegEx Built an accordion from scratch Exited VIM Accidentally created own CMS Pulled

Read More »
sendinblue