• I want tmy theme to deiplay each post in a certain way depending on he catagory. The reason for this is I use the site to display my twitter updates too. Thisresults in lots of updates. So i want to make the twitter posts smaller than normal posts.

    This is how the site displays posts at the moment:
    Current Look

    This is what it should look like:
    New Look

    I appreciate that itb will involve some CSS but i ill deal with that once i have the Loop sorted. This is the code so far but it dosn’t work. I think i need to create a loop within the main loop.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    			<?php $post = $wp_query->post;
          if ( in_category('28') ) {
          include(TEMPLATEPATH . '/tweet_cat.php’);
          } else {
          include(TEMPLATEPATH . '/cat.php');
          } ? >	
    
    			<?php endwhile; else: ?>
    
    			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    			<p><?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?></p>

    tweet_cat.php and cat.php are 2 simple files displaying the relevant tags in the order they should be arranged in for the diffrent catagories.

    I just don’t know how to code it to do this nor do i know if it’s beyond WP capabilities.

Viewing 2 replies - 1 through 2 (of 2 total)
  • This should work:

    <?php if(have_posts()) : while(have_posts()): the_post(); ?>
    
    <?php
    if(in_category('28')) {
    	include(TEMPLATEPATH . '/tweet_cat.php’);
    } else {
    	include(TEMPLATEPATH . '/cat.php’);
    }
    ?>
    
    <?php endwhile; else : ?>
    
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    <p><?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?></p>
    
    <?php endif; ?>

    Notice I took a couple of things out that were unnecessary (like defining the $post varialbe. the_post() function already does that).

    The only variables are the 2 files you’re pulling in. If they contain new loops, and not just in-loop template tags, then it could screw some things up. If the code I gave you above doesn’t work, then the problem is in those 2 files somewhere.

    Thread Starter irishmark

    (@irishmark)

    That does work but it doesn’t achieve what i want

    I want to be able to use diffrent templates on the same page

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display posts in diff template layouts using loop within a loop’ is closed to new replies.