• I am using version 1.0.4 of the Ajax Calendar.

    I am using this short code in a widget in order to display a short list of the next 5 upcoming events, like this:

    [eventlist limit=5 categories="1"/]

    It works fine except that it does not always display the current day’s event or the next day’s events. It may display events starting a day or two in the future.

    Here is the home page that shows the problem.

    http://www.wehelpothers.com/

    Today (as an example) on the 26th there is an event scheduled for later today, one scheduled for the 27th, and one scheduled for the 28th. On the sidebar only the 28th and not the two earlier events in between now and then are displayed. If you proceed to the full calendar page you see the events scheduled today and tomorrow.

    Is this related to the start day of the week setting in WP?

    People can, of course, always go to the full month display to see everything. But short list should be accurate and it’s not.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Elle

    (@azjaleah)

    I see you have resolved this somehow. I am having the same problem when I use more than one category to draw from. A list of classes – first two are yesterday, next occurrences show next week instead of starting with today and listing from there.

    This is the shortcode I tried:
    [eventlist limit=7 whitelabel="true" categories="1,2,4" end="+2 Days"]

    Actually I tried every variation of start and end, categories, etc. The only one functioning properly is
    [eventlist limit=7 whitelabel="true" categories="1"]

    I have not tried disabling plugins yet to find any conflicts. Did you?

    It’s a bug in the shortcode – see my post “Bug in Eventlist shortcode” – I offer a hack to the code to work around the problem – adding 2 line to the php source code – not ideal, but may work for you until author is able to fix the issue
    HTH
    Chris

    Hi, Chris,
    Thanks so much for posting here! I can’t tell you how appreciative I am that you took the time to not only post the bug, but to provide a solution for it.

    I added this at line 793:

    $limit = $limit *7; // temp bugfix add this to increase limit here
    $events	= $this->db_query_events($start, $end, $categories, $excluded, $limit);
    $limit = intval($limit/7); // temp bugfix add this to restore limit

    Adding that code didn’t do the trick but I noticed that the second line of your code was repeated below it. So I deleted the second instance of this:
    ‘$events = $this->db_query_events($start, $end, $categories, $excluded, $limit);’

    So for those like me who are not schooled in php, this is the way the code changes given by you should look:
    Line 793: $limit = $limit *4; // temp bugfix add this to increase limit here
    Line 794: $events = $this->db_query_events($start, $end, $categories, $excluded, $limit);
    Line 795: $limit = intval($limit/4); // temp bugfix add this to restore limit
    Line 796: $events = $this->process_events($events, $start, $end, true);
    and on….

    This is the shortcode used:
    [eventlist limit=7 whitelabel="true" categories="1,2,3,4"]

    Note that I changed the code to $limit *7 because I was using 7 events – I’m not sure if that matters. This fix you posted did not affect any other eventlist instance used on the site.

    Again, thanks so much! You’re a genius!

    @azjaleah You’re welcome!
    Yes, there should only be one line that does the db_query_events!

    To answer your question, [ eventlist limit=7 … is fine, just set however many result you want as a maximum, you can change that at any time, just like before.
    This is because the number 4 on lines 793/795 does not relate to the shortcode limit number.
    What I found was that the events you expect to display are not always fetched within the query $limit. But if the query fetches MORE records then it does find the right ones. So what my patch does it does is tell wordpress to get “4 times the number of results you set in the shortcode limit”. Because you only want to DISPLAY the number set in the shortcode, it restores the number back to original immediately afterwards, so that the code further on displays the number you set (7 in this case).
    I tested with doubling it, and that seemed ok, so doubled again to be safe. The number on lines 793/795 MUST be the same, so it restores back to the original!
    Glad it helps!
    I don’t guarantee it will work for every number of categories and every quantity of events, as that can be so variable and I only tested a few different situations, but it has been behaving ok on my own site.

    Hopefully the author will revise the code so that this is not needed!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Short Code Does not Always Display the Next Couple of Events’ is closed to new replies.