• Resolved Dying2Live

    (@dying2live)


    So I created a template and I’m trying to query specific posts with different tags within the same category by page using a conditional statement. I’m not the greatest at php and was wondering if someone might be able to help me out or point me in the right direction.

    Thanks in advance.

    My code:

    <?php
    if (is_page('1'))
      {
       Loop 1
      }
    elseif (is_page('2'))
      {
      loop 2
      }
    else
      {
      //default loop of all tags within category 21//
      <?php $args = array('cat' => '21', 'posts_per_page' => 10, 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),); query_posts($args); while (have_posts()) : the_post(); ?>
    	<?php global $more; $more = 0; ?>
    	<div class="blue">
    		<div id="post-header">
    			<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    			<div class="clear"></div>
    			<p>Posted on <?php the_time('F jS, Y'); ?> by <?php the_author(); ?></p>
    		</div>
    		<div class="clear"></div>
    		<div class="entry">
    			<?php the_content('Read More...'); ?>
    		</div>
    		<div id="post-footer">
    			<p><?php comments_popup_link('Respond to this post &raquo;', '1 Response &raquo;', '% Responses &raquo;'); ?> &bull; <?php the_tags('Tags: ', ', ', '<br>'); ?></p>
    		</div>
    		<div class="clear"></div>
    	</div>
    	<?php endwhile; ?>
      }
    ?>

    The default query works by itself but when I place it in the conditional statement I get an error.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is this code being used in a custom page template file?

    Thread Starter Dying2Live

    (@dying2live)

    Yes it is.

    Thread Starter Dying2Live

    (@dying2live)

    So I actually got it to work.
    I changed the conditional statement to this:

    <?php
    if (is_page('leadership')) { include (TEMPLATEPATH . '/inc/leadership.php'); }
    elseif (is_page('marketing')) { include (TEMPLATEPATH . '/inc/marketing.php'); }
    elseif (is_page('operations')) { include (TEMPLATEPATH . '/inc/operations.php'); }
    elseif (is_page('talent')) { include (TEMPLATEPATH . '/inc/talent.php'); }
    else { include (TEMPLATEPATH . '/inc/knowledgebase.php'); }
    ?>

    Then I just placed each query in its own php file.

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

The topic ‘Multiple loops with in a conditional statement’ is closed to new replies.