Title: Excluding Categories Based on Current Date
Last modified: August 19, 2016

---

# Excluding Categories Based on Current Date

 *  [jfudem](https://wordpress.org/support/users/jfudem/)
 * (@jfudem)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/excluding-categories-based-on-current-date/)
 * Hi All,
 * BACKGROUND
    I’m designing a site which will act as a biweekly PA system for my
   school. Every Week we have two assemblies and my site will organize posted announcements
   and display them, one at a time, in slideshow fashion. The posts for each assembly
   are stored in categories named for the Assembly’s date (mm/dd/yyyy). The homepage
   of the site displays all the categories in ascending order. Since we have two
   assemblies a week, though, we are going to have to create a lot of categories.
   I think it would be a little overwhelming to visit our site and see dozens of
   links to older assemblies, which have already happened, and future ones, which
   are still months away.
 * WHAT I WANT TO DO
    I’d like to write some PHP, which would get the current date
   in mm/dd/yyyy form and compare it to the category title. If the category title
   lists a date before the current date, or if the month value is two greater than
   the present month, the PHP will exclude the category from visibility on the front
   page. That way we would only ever show the viewer upcoming Assemblies.
 * I’m also working on admin theme, since many of our users will be posting announcements
   themselves, and I would like to also be able to run this script on the select
   a category box, in the post editor for similar reasons. NOTE: I have already 
   designed the admin theme so that it only affects low level users, so I only would
   be altering the category widget for contributors.
 * HOW DO I DO IT?
    I’m still learning PHP and I was wondering if anyone has any
   ideas about how to approach writing this script. I know it is possible to use
   PHP to compare a given date to the current date as seen [here](http://www.codingforums.com/archive/index.php/t-34300.html).
   But, I’m unsure how to compare the current date to each category, as if it was
   a date value, and then either display, or exclude that category from visibility.
   Perhaps using a “Foreach” script. Currently I use “wp_list_categories()” to display
   the links on my homepage. I know that this tag has an exclude parameter but it
   only accepts category IDS, so I might need to get the category’s ID once the 
   category has been compared to the current date, assign the ID to variable, which
   would then be excluded by “wp_list_categories().” But, I’m not quite sure how
   to do all this
 * Please let me know if you have any suggestions about how to accomplish what I’m
   looking for. I realize I’m ambitious here, but I am pretty good at learning quickly
   the skills I need to accomplish a specific task. I really appreciate your attention.
   Sorry for such a long post too.
    Best, Jonathan
 * Some Other Information Which May Be Useful:
    – I’m running WordPress 3.1 on a
   multisite network – My site uses a custom Child Theme for Thematic

The topic ‘Excluding Categories Based on Current Date’ is closed to new replies.

## Tags

 * [custom home page](https://wordpress.org/support/topic-tag/custom-home-page/)
 * [exclude categories](https://wordpress.org/support/topic-tag/exclude-categories/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jfudem](https://wordpress.org/support/users/jfudem/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/excluding-categories-based-on-current-date/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
