• Hi,

    Is it possible to search for only events that are active?
    So if you set start date 2018-10-25 and end date 2018-11-01 it should show up in search results. But if it has start date 2018-10-25 and end date 2018-10-26 it should not show up. And same thing with events in the future.

    Is it possible to do this?

    Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Guido

    (@guido07111975)

    Hi,

    How do you search for those events, via a certain search string in the address bar of your browser or via a (custom) search form?

    Guido

    Thread Starter jockebq

    (@jockebq)

    @guido07111975
    At the moment with this <?php get_search_form(); ?>
    But that results in searching the whole WordPress page, which I don’t want either. I just want to search and find today’s events.

    • This reply was modified 6 years, 5 months ago by jockebq.
    Plugin Author Guido

    (@guido07111975)

    You have tagged the wrong Guido.. my ID is @guido07111975
    (you can edit your topic within 30 minutes)

    This might be very difficult because native search doesn’t search within custom fields, such as date, time, location. Guess you need a custom search form for this. I have to think about it.

    Guido

    Thread Starter jockebq

    (@jockebq)

    Is it possible to filter the search results page? To do a check against the meta data or something?

    Plugin Author Guido

    (@guido07111975)

    Hi,

    The only plugin I know that does a good job with custom search is Search Everything. Unfortunately this one is not being maintained anymore. Hopefully it still does work properly. You can try that one.

    Guido

    Thread Starter jockebq

    (@jockebq)

    Would it be possible to do without any additional plugin? I have created a custom theme and page template for search.

    Plugin Author Guido

    (@guido07111975)

    Hi,

    If you’re using a custom search template you should consider adding a custom search form.. but this is quite a lot of work, please check this tutorial.

    Guido

    Thread Starter jockebq

    (@jockebq)

    @guido07111975
    You were right, that was a lot of work.
    I have another idea, but don’t know if I can make it work:
    Using this code:

    function SearchFilter($query)
        {
            if ($query->is_search) {
                $query->set('post_type', 'event');
            }
            return $query;
        }
    add_filter('pre_get_posts', 'SearchFilter');

    This works good to make search only work for event post type. But would it be possible to somehow get the $today or event-start-date + event-end-date to only include todays results?

    Plugin Author Guido

    (@guido07111975)

    In that tutorial there’s also a section about using custom post type fields.

    Guido

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Search only today?’ is closed to new replies.