Add Tribe Events Search Bar To Your Home Page

I recently did a project for a company that hosted different events on their yacht. They wanted a way to sell tickets to their events through their website. This was easily accomplished through the use of Modern Tribe’s Event Calendar. This was a great solution except for the fact that the plugin did not come with an option to add a search bar that would allow users to search for events by date or keyword the home page.

This was almost a deal breaker for me as you want to get users to events with as few steps as possible, but the functionality of the plugin was so good I went ahead and used it for the project, and decided to figure out how to add the events search bar to the home page as a side project, then add it to UberVida as a bonus.

How To Added The Search Bar To Your Website

The first thing that you need to do is get the code for the search bar which can be found in the plugin folder the-events-calendar > views > modules > bar.php

This is the modified version that I used on the homepage:

The main changes that I had to make where to the form this is the original:

The  form [su_highlight]method[/su_highlight] and [su_highlight]action[/su_highlight] had to be changed to get and the URL of the events:

Next I had to enqueue the styles for the search bar as well as the scripts for the date picker as is suggested on the Tribe Forum. But for whatever reason the styling worked fine however the datepicker didn’t. I was lucky in the fact that I could see that the datepicker that Tribe uses was an addition to the bootstrap framework that I am familiar with and I was able to download the necessary datepicker scripts. Then I wrote a plugin so that these scripts would only be called on the home page.

You can download the plugin here.

18 Replies to “Add Tribe Events Search Bar To Your Home Page”

    1. Hi Henrik,

      Try using the following:

  1. Hi, thanks for getting back to me.
    Yes, fine – i managed to do the same. However – i can’t get the datepicker to work. (doesn’t show)
    And – the mobile view mess up the css.
    Any advice?

    1. If the date picker is not working there may be an issue with the path to it. I had issues using the date picker path that tribe uses, that was one of the main reasons for the plugin. You could use something like firebug to see if they’re any errors.

  2. Hi, could not find an error with datepicker. However – i thought i should scale it down to only include locations search on homepage.

    However – when hitting submit – it does send the right information to /events/ – however it does not generate the results based on that search – it lists all. Another problem is that it does not show (on frontpage) the input selections (if entering a city or street where there are alternatives) when hitting submit – as it should.

    Not asking you to solve this for me – just thought i would ask if you might know what the problem is. If you like to see the page under construction – it is here: http://artgoons.com/
    You need a password for the site: nyfiken

    Just very frustrating this… trying to get a simple search form to work on fronpage… 🙂

    1. Hi, I haven’t had much time to look into this, but a quick fix maybe to set the default view to map. From what I could see the geo location for the longitude and latitude are missing. This could probably be enabled on the home page if you could find out what part of the Tribe plugin controls the Ajax Geo location. When I have time I’ll see if I can figure it out.

      1. Is there a solution for this? I have the same problem. When hitting submit it doesn´t show the filtered events.

  3. I’m also very interested in adding the Tribe search bar to my homepage. I’m not a developer, so I need something that runs out of the box. What would work for me is an events search widget that I could simply add to the main sidebar of my theme. Is something like that available, or could it be?

    1. Hi Rex,

      I have not heard of anything like that, but I should be able to adapt the code into a plugin that would allow you to add the tribe search to the widget area, or as a short code in any post/page. I have a couple of other projects going on right now, but I’ll put this on the todo list.

  4. Thanks for all your help, Greg.

    I’ve the same problem as Rex, I’m not a developer and would be great to have the search bar in a shortcode or widget… hope you soon have time to adapt your codes.

    Thank you again!

    1. No problem Emilio. Trying to spend some time on it this weekend, but I’ve also got a couple of new articles that need publishing, hopefully it’ll all get done this weekend.

      #NewYearNewMe

  5. Hi!
    Great code-work here – helped me a lot!
    I implemented the bar on the homepage and another page using the same code like for the homepage.
    But on the other page the datepicker isn´t opening.

    Also on both pages I get two console errors:
    Uncaught ReferenceError: tribe_ev is not defined (tribe-events-bar.js)
    Uncaught ReferenceError: tribe_js_config is not defined (tribe-events.js)

    Do you have an idea what is causing this problem?

    1. Hi Vivianne,

      Sorry for the delayed response, I believe some of the code is written so that it is only called on the home page, something like “is_home”, if I remember correctly. That’s probably what is causing your issue.

  6. You sir are a legend! Tribe are good for feedback but living in England there’s the timezone problem for hearing back from them, and then they don’t always help with custom code. Again, thanks a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *