Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter minnys

    (@minnys)

    Thank you. I have successfully done this as well. The issue is fully resolved. Either I was selecting the wrong setting or an update of the plugin has fixed it. Thank you for putting up with me!

    Thread Starter minnys

    (@minnys)

    Nevermind, please ignore my previous message. I have resolved the problem. Thank you everyone for putting up with me. My apologies for all these posts. If anyone wants to know my solution to the problem and what my multiple mistakes were, my explanation is as follows.

    I edited the code from the “Create Your Own Event” article and installed it on my site as a WordPress plugin. The first time I created the plugin, being brand new to coding plugins, I just copied and pasted all the code blocks from the article in the order they appeared. That was the first thing I did wrong. I realize now that the following line of PHP was only supposed to appear once in the plugin file:
    $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))";

    To understand my second mistake, you need to see the following chunk of code I used:

    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
        $my_scopes = array(
            'today-future' => 'Today and Future'
        );
        return $scopes + $my_scopes;
    }

    When I tried to use the new scope in a shortcode, I set the scope attribute to ‘Today and Future’. I understand now that I needed to set the scope attribute to ‘today-future’. When I set the scope attribute to ‘today-future’, the shortcode worked in other browsers.

    The reason my solution from two posts ago did not work in other browsers was because some browsers apparently aren’t compatible with the PHP Code Widget by Otto.

    Following is the full plugin code I am using now (except for the plugin header). Most of the code I copied and pasted from the “Create Your Own Event Scope” article:

    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']=='today-future' ){
            $start_date = date('Y-m-d',current_time('timestamp'));
            $end_date = date('Y-m-d',strtotime("+12 months", current_time('timestamp')));
            $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;
    }
    
    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
        $my_scopes = array(
            'today-future' => 'Today and Future'
        );
        return $scopes + $my_scopes;
    }
    • This reply was modified 5 years, 7 months ago by minnys.
    Thread Starter minnys

    (@minnys)

    I’m sorry, I posted too soon (rookie mistake). My solution didn’t work in all browsers (such as Safari). I don’t know how to remove the “Resolved” mark from this forum thread, so if a someone could please do that for me it would be much appreciated. So sorry to pester everyone.

    Basically, my question now is: Where do I put the code from the “Create Your Own Event” article? Please see my previous response for details. Thank you!

    Thread Starter minnys

    (@minnys)

    Thank you everyone for your help.

    @duisterdenhaag, I already made sure current events are not regarded as past events.

    @angelo_nwl, thank you the link. I could not figure out where to put the PHP code from the article. I tried putting it in a plugin; then I tried saving it as a code snippet using the “Code Snippets” plugin by Shea Bunge. I also tried embedding the PHP (using plugin “PHP Code Widget” by Otto) in the page in which I needed to display the event/s. None of these actions worked. Where do I put the code from the article?

    My solution: I ended up installing “PHP Code Widget” by Otto, which saved the day! After research combined with trial-and-error, I came up with the following code. I put the following code into the PHP code widget, and now it shows events from both today and the future!

    UPDATE: My solution does not work in Safari browser or Firefox Private Windows! Please see my previous bolded text.

    <?php
    
    echo do_shortcode(
    
    '[events_list scope="'. date('Y-m-d', current_time('timestamp')) . ',' . date('Y-m-d', strtotime('+5 months', current_time('timestamp'))) . '" category="featured" limit="1"]
    #_EVENTLINK&nbsp;will take place at #_LOCATIONLINK on #_EVENTDATES from #_EVENTTIMES
    [/events_list]'
    
    );
    ?>
    • This reply was modified 5 years, 7 months ago by minnys.
Viewing 4 replies - 1 through 4 (of 4 total)