• Resolved val-13Love

    (@val-13love)


    Hi

    I am trying to find a way to only display future events when running a search. I have amended the settings Pages -> Event List/Archives -> Event List Scope = Future Events, however I am still getting past events displayed.

    I have tried resetting events manager as a forum post I found suggested but still the same thing, past events are coming up as search results.

    Here’s a link: http://www.black-gold.biz/index.php?s=Jimmy+Cliff
    (As you can see old events have old styling so really need to not have these displayed)

    Any advise on how to get the search to only show future events would most appreciated.

    Thank you in advance
    Val πŸ˜€

    https://wordpress.org/plugins/events-manager/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter val-13Love

    (@val-13love)

    Just realised the following might be useful to those trying to help:

    // INCLUDE EVENTS IN SEARCH RESULTS
    if(!function_exists('cw_add_to_default_search')) {
    function cw_add_to_default_search() {
    global $CORE, $CORE_CART, $PPT, $wpdb;
    //INPUT YOUR CUSTOM POST TYPE HERE
    $new_post_type = 'event';
    //ADD TO $GLOBALS['post_type'] ARRAY
    if(isset($GLOBALS['post_type']) && is_array($GLOBALS['post_type']) && !in_array("$new_post_type",$GLOBALS['post_type'])) { $GLOBALS['post_type'][] = "$new_post_type"; }
    }}
    add_action( 'hook_wlt_core_search', 'cw_add_to_default_search' );

    This is the code I was told to add to my functions (by the theme developer) in order to allow for events to be included in the search results. Because the theme I’m using does not automatically include custom post types in searches.

    Your help would really be appreciated as this is the final fix required for the site.

    Thanks in advance.
    Val πŸ˜€

    Plugin Support angelo_nwl

    (@angelo_nwl)

    did you try Events > Settings > Pages > Event List/Archives > WordPress Event Archives ?

    Thread Starter val-13Love

    (@val-13love)

    Hi Angelo

    I have tried it with:

    Events > Settings > Pages > Event List/Archives > WordPress Event Archives > Enable Archives?

    Set to Yes and No and it makes no difference to what results are displayed, I still get past events being displayed. I have also tried changing:

    Events > Settings > Pages > Event Pages > Display events as

    Again it doesnt matter if I have this set to Posts or Pages it still displays past events in the search results.

    Also just as a mention (in case there’s a connection) in trying the different options above I thought let me adjust the search results order to show the date coming soonest first. But no matter what option I select it always shows the event farthest away(in date) first. Could this be linked to why I keep getting past events also?

    Thank you in advance
    Val πŸ˜€

    caimin_nwl

    (@caimin_nwl)

    If you remove the custom code you pasted above, does that fix the problem?

    Thread Starter val-13Love

    (@val-13love)

    Hi Caimin_nwl

    Unfortunately not. Without the code above events are not displayed at all in search results.

    But even when I have tried switching back to the wordpress twentyten theme the search results still shows the past events.

    Any idea what I can do to remove past results from the search results.

    Much thanks
    Val πŸ˜€

    caimin_nwl

    (@caimin_nwl)

    Have tried setting Include in WordPress Searches to yes under Events > Settings > Pages > Event List/Archive instead of using your custom code?

    Thread Starter val-13Love

    (@val-13love)

    Hi Caimin_nwl

    Yes I have tried this both with and without the custom code and also in the twenty ten theme (just to be sure). Yet I still get events which have passed displayed in search results. I have also reset the plugin and still past events are displayed in search results.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    this works for me, can I know what is your current EM version?

    Thread Starter val-13Love

    (@val-13love)

    Hi Angelo

    Apologies for delayed response. I am using EM version 5.5.2 but it’s always been like this and I’ve been using it for about a year. Wasn’t an issue before as I didn’t have many past events, but with the number of past events growing search results will end up with more past events than current events.

    In case it helps I have also deactivated all plugins and tried adjusting the settings as detailed above but still no change and that was after I reset EM as well.

    I’m seriously stumped. Although I don’t think it should have any effect but I think it best to ask, does the formatting for your date in site settings make a difference because I have mine set to custom: d M Y

    Again thanks in advance for the assistance.
    Val πŸ˜€

    Plugin Support angelo_nwl

    (@angelo_nwl)

    can you try EM dev version 5.5.2.1 ? To upgrade to the dev version see here – http://wp-events-plugin.com/documentation/upgrade-dev-version/

    Thread Starter val-13Love

    (@val-13love)

    Hi Angelo

    I have tried the dev version and still the same result, search results display events which have passed.

    The only thing I can think that may work is to combine the above code with a custom scope code, eg:

    //ADDS A THIS WEEK SCOPE
    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope'] == 'this-week' ){
    		$start_date = date('Y-m-d', strtotime('Last Monday', time()));
    		$end_date = date('Y-m-d', strtotime('Next Sunday', time()));
    		$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
    	}
    	return $conditions;
    }

    Although scope would be set for a year or two rather than a week.

    Your help with this would be greatly appreciated as I only have a basic understanding of html and wouldn’t know were to start with combining the code.

    Or if you have any suggestions please let me know.

    Thank you in advance
    Val πŸ˜€

    Thread Starter val-13Love

    (@val-13love)

    Hi

    I don’t think events manager is working. I have not only deactivated all other plugins and themes (using WordPress twenty ten) but I have deleted them too and still the WordPress search results display past events.

    I am also using version 5.5.2.3 (dev version) as suggested and still no joy.

    Is anyone able to suggest a way to get events manager to display only future events in the WordPress search results please.

    Thanks in advance
    Val

    Plugin Support angelo_nwl

    (@angelo_nwl)

    maybe you can try this snippet – http://pastebin.com/zpFaWvrm

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Search results set to future but also showing past events’ is closed to new replies.