• Resolved rinse

    (@rinse)


    I’m trying to create a site that knows what day of the week it is (monday thru sunday) and can display posts according to that day.

    I hypothetically want to be able to make a post, and put it in a category titled a day of the week. From there I want wordpress to understand that i want posts filed under “Monday” to show up on the main page on Monday, “Tuesday” on tuesday, “Wednesday” on wednesday, etc.

    The point of the blog is to display coupons that are only valid on a certain day of the week. So when a viewer comes to the site on wednesday the main page shows all the posts I’ve filed under the “Wednesday” category.

    So the question is: Is WordPress somehow able to do this without too much difficulty, and if so can somebody point me in the right direction.

    thanks in advance, hope it makes sense.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes. WordPress is time and date “aware”.

    Dashboard > Settings > General > Time Zone and Time Format > Week Starts on…

    Posts will appear on the date you set them to appear, or immediately, if not otherwise specified.

    If you create categories that correspond to days of the week, then the content that appears there, depends on you assigning that category ( presumably a day of the week ) to a specific post when you create it.

    Thread Starter rinse

    (@rinse)

    sorry not exactly what i meant. i knew that much. it’s not just a specific day, it’s every monday for example, or every tuesday.

    i need the code so my main page thinks:

    if it’s monday only display posts filed under ‘monday’
    if it’s tuesday only display posts files under ‘tuesday’

    i might be over thinking this.

    You could do something like this with basic php

    <?php
    // get current day:
    $currentday = date('l');
    
    // query posts where category equals current day:
    query_posts('category_name='.$currentday);
    
    // wordpress loop code here
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    ..
    endwhile; else:
    ..
    endif;
    ?>
    Thread Starter rinse

    (@rinse)

    thank-you so much blueinstyle.
    works perfectly, exactly what i need.

    much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘does WordPress know the day of the week?’ is closed to new replies.