Display posts tagged with current day
-
Currently my main page needs to display a different set of posts on every day of the week. To accomplish this I made seven categories each named a different day of the week… From there I used the below to only get those posts with a category name that matched the name of the current day.
<?php // get current day: $currentday = date('l'); ?> <?php global $post; $today = get_posts('numberposts=6&category_name='.$currentday); foreach($today as $post) : setup_postdata($post); ?> post stuff. <?php endforeach; ?>
The problem now is I’ve split my sites content into two different sections, and I want the stuff from both sections displaying on my main page. Where the problem lies is in my added category structure my ‘daily’ categories no longer have a slug of just ‘monday’ or ‘tuesday’…
the new ones are ‘monday-stuff’, ‘tuesday-stuff’ etc. how to I go about adding the new slug to something like $currentdaynew? And from there displaying only categories $currentday & $currentdaynew? I know next to nothing about php so any help would be much appreciated.
- The topic ‘Display posts tagged with current day’ is closed to new replies.