I’ve been integrating client web sites with a popular WordPress plugin in called “Events Manager” that allows me to show show events in my sidebar:
I can also show events as a one month calendar:
One feature that was really missing from this plugin was search. There simply is no integration with the powerful search capability in WordPress for this plugin because of how this plugin was designed, it doesn’t use Posts therefore WordPress doesn’t know what to search.
My solution was to update the search.php file in my theme template by adding the following PHP code to search the custom table used by this plugin:
Line 13 is the name of the database table used by the plugin, in my case: wp_em_events.
Line 14 is where we get the search string that our web visitor has typed.
Lines 17 to 19 are where we query the database table looking for any matches with the search string in the event name or the event notes.
Lines 21 thru 27 will display all the events that match our search. On one client site the results look like this:
For my search.php file I inserted the custom code just above The Loop.
I love the power of re-using a WordPress plugin to enhance a web site however sometimes I have to get in there and do some PHP and database coding to get the feature that I need to complete the plugin.