• Resolved sollers

    (@sollers)


    Hello,

    I’d like to show specific category for specific day.

    I wrote code for one day and it works, but I don’t know how to form elseif statements for all 7 days.

    <?
        $test = date("N");
        query_posts('cat=100&showposts=1');
    	if ( $test == 7 & have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
              <div class="contentdiv">
    	       <div class="bg"><img src="http://img.com/white.jpg" width="50px" height="50px"/></div>
                  <div class="txt">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<div><div align="center"><?php the_thumb("subfolder=200x150&dirname=4&LINK=p&WIDTH=200&HEIGHT=150"); ?></div><?php the_excerpt(); ?></div>
                  </div>
              </div>
    		<?php endwhile; ?>
    	<?php endif; ?>

    Thank you for any insight!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think this is what you want (with your own category id’s):

    <?php
       $test = date("N");
       if ($test == 7) {
          $cat = 100;  // Category for Sunday
       } elseif ($test == 6) {
          $cat = 6;    // Category for Saturday, etc
       } elseif ($test == 5) {
          $cat = 5;
       } elseif ($test == 4) {
          $cat = 4;
       } elseif ($test == 3) {
          $cat = 3;
       } elseif ($test == 2) {
          $cat = 2;
       } elseif ($test == 1) {
          $cat = 1;
       }
       $args = array(
          'cat' => $cat,
          'posts_per_page' => 1,
       );
       query_posts($args);
       if ( have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
    Thread Starter sollers

    (@sollers)

    Works like a charm 🙂

    Thank you!

    You are welcome!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘7 days & 7 categories’ is closed to new replies.