Search Form in archive-event template

WordPress Event Management, Calendars & Registration Forums General Question Search Form in archive-event template

This topic contains 6 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 8 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7134

    I’ve added the search short code to the archive-event template. I have a bug that when i try to search it loads the first event in the list instead…

    try to search here: http://78.129.175.88/~sapphire/events/event/

    I’ve amended the search template to only show search results if searched, but I think I need the search results page to be a new page, how can i do this?

    Daniel Peters
    #7136

    Hi Daniel,

    The event search shortcode was originally intended for use on a separate page.

    If you want to display the results on a different page this is possible, with a bit of hack (I will consider adding options to the shortcode to make this easier).

    • First create the results page with the event search shortcode
    • Edit _eventorganiser_event_search_shortcode_handler() in includes/shortcodes.php. Specifically line 103 and replace '.get_permalink().' in <form action="'.get_permalink().'" method="get"> with the url of the results page.

    That way, the search form posts to your results page. You can hard-code it if that suites, or this article allows you to get a page’s url from its page title: http://tommcfarlin.com/get-permalink-by-slug/.

    Note that changes made to the core-plugin files will be lost when you update (and 1.4 has just reached beta). I shall keep you posted about including an option to make this possible without editing the plug-in files, and that will hopefully be in 1.5.

    Stephen Harris
    #7139

    Thanks a lot I’ll try this now!

    Daniel Peters
    #7140

    I’ve done this but it still seems to be posting to the events/event page: http://78.129.175.88/~sapphire/events/event/ the form shows this now:

    <

    form action=”http://78.129.175.88/~sapphire/events/search-results/” method=”get”>

    • This reply was modified 10 years, 8 months ago by  Daniel Peters.
    Daniel Peters
    #7142

    Sorry, after that, change:

    sprintf( '<input type="hidden" name="page_id" value="%d">', get_the_ID() )
    

    so that get_the_ID() is replaced by the ID of the results page. Also, the results page will need to have the event search shortcode to display any results (after making that alteration in my browser it correctly displasy the results page – but its blank).

    Stephen Harris
    #7143

    Thank you, this seems to be working great now! 🙂 Really appreciate your speedy help! 😀

    Daniel Peters
    #7145

    No worries :). I will probable had a ‘page ID’ attribute to specify a different results page in future versions.

    Stephen Harris
Viewing 7 posts - 1 through 7 (of 7 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.