Calendar Plus
Restrict Legend to Currently Shown Categories (1 post)

  1. Katherine
    Posted 5 years ago #

    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;
    $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!


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Calendar Plus
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

  • RSS feed for this topic
  • Started 5 years ago by Katherine
  • This topic is not a support question
  • WordPress version: 3.2.1