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.
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; ?>
You should try something like this,
Using WP_Query
Using query_post: