• I also posted this to the plugin developer’s site, but I’m sure WP.org gets far more visits…

    In case this comes in handy for anyone else, here’s a fix I worked out for making sure that a calendar’s legend shows only the categories which are currently displayed (instead of the default, which is ALL categories). It’s just a few simple edits to the calendar.php file.

    First, under the calendar_insert() function, add a global variable called “catFilter”. Then, in the loop:

    if (strlen($search) >0)
    {
    $sqlFilter = "AND event_category IN ($search) ";
    $catFilter = $search;
    }
    else
    {
    $sqlFilter = "";
    $catFilter = null;
    }

    If desired, you can also modify the calendax_insert() function the same way.

    At the beginning of the calendar() function, call the global variable again. Then, modify this line:

    $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " ORDER BY category_name ASC";

    to read like this

    $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id IN (" . $catFilter . ") ORDER BY category_name ASC";

    That’s it!

    http://wordpress.org/extend/plugins/calendar-plus/

  • The topic ‘[Plugin: Calendar Plus] Restrict Legend to Currently Shown Categories’ is closed to new replies.