Elementor listing search form widget

So i’ve got the listing search form from elementor on the home page, like in the demo template.

But where does it leads ?

The result page do not look like when I do a search either on experts/vendor or requests pages.

And can we change the query ?

Make it do a search and result in the requests or vendors, not listing.

Thank you :slight_smile:

lolo

Hello Buddy,

Difficult to help you without looking at your website, I am afraid.

What I can tell you, in any form, you have an action parameter.
This is generally the returning page being displayed, when you do a query.

If your resulting page looks like https://myawesomewebsite.com/?s=test
where ‘test’ is the param you entered, using the GET method this is the default behaviour for any website based on WordPress.

HivePress passes some extra parameters, such as post_type=hp_vendor, hp_listing, hp_request, depending on the page you are on, to niche down your search to such or such entity.

So you may have to pass this extra param, as hidden field for instance.

Your Elementor may even add some complexity to it, by triggering the search results in Ajax.

Your call, your problem :wink:

Hi mate ! :slight_smile:

I did that :

add_action('wp_footer', function() {
   if(!is_front_page()) return;
   ?>
   <script>
   jQuery(document).ready(function($) {
       $('.hp-form--listing-search').on('submit', function(e) {
           e.preventDefault();
           let fullUrl = this.action + '?' + $(this).serialize().replace('hp_listing', 'hp_request');
           //alert('URL: ' + fullUrl);
           window.location.href = fullUrl;
       });
   });
   </script>
   <?php
});

So it intercepts the form query and replace
hp_listing
with
hp_request

That’s what i wanted but for anybody who reads that you can change it to “hp_vendor” as well.

It only works on the home page for my needs too, i dont want that interception done on other forms :slight_smile:

That’s a bit cheeky but perfectly does the job :slight_smile:

jQuery mastery is an underestimated skill.
I love it !

Hi,

Let me know if you have solved this issue. Also, please note that we currently don’t 100% support Elementor - while you can add HivePress blocks via Elementor, advanced features are not available yet. I highly recommend using the core WordPress block editor to keep the website fast and lightweight.

Hi @andrii

I thought my reply was clear enough, i cleared myself out and posted my solution for whoever is in the same case a me.

1 Like