• 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. 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.