Display a custom WordPress taxonomy tag automatically based on the day of the week?

I’ve got a client that wants to display custom taxonomy tags automatically by day of the week in WordPress. Basically, we’ll have a custom post type called “products” and that will have a taxonomy called “day.” Within “day” we’ll have seven tags, one for each day of the week, and anything tagged with a specific day of the week will display on that day on the home page.

So, for example, if Product A, B & C are all assigned a tag of “Wednesday” within the taxonomy “day” and today is Wednesday, then those items will display on the home page. If products D, E & F are assigned Thursday, they’ll show up on Thursday, and so on.

Read More

With all that said, the part I need help with is writing a loop that can detect the day of the week and then query the proper taxonomy tag. Does anyone have any idea how to go about this? I really can’t find any reference on this and my PHP skills are rudimentary at best. :-/

Here’s the loop I’m currently using to display products manually by custom post type, taxonomy & term:

<?php query_posts('post_type=products&taxonomy=day&term=wednesday&posts_per_page=10'); ?>
<?php if(have_posts()) : while (have_posts() ) : the_post(); ?>
<div class="archivecustompost">
<div class="archivecustomleftblock">
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( array(150,150) ); ?></a>
</div>
<div class="archivecustomrightblock">
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<p class="button"><a href="<?php the_permalink() ?>" rel="bookmark">Learn More</a></p>
</div>
</div>
<?php endwhile; endif; ?>

Related posts

Leave a Reply

1 comment

  1. You should try something like this,

    Using WP_Query

    $day = date("l"); // Gives the todays day.
    $wpq = array (post_type =>'product','taxonomy'=>'day','term'=>$day);
    $query = new WP_Query ($wpq);
    

    Using query_post:

    $day = date("l");
    $args = 'post_type=products&taxonomy=day&term='.$day.'&posts_per_page=10';
    query_posts($args);