Support » Themes and Templates » getting the loop to pick Cat Templates perpost

  • I’m trying desperately to do some hardcore WordPress theme development and i fear i am a wee bit over my head. However, usually when i do something stupid and try and make the site do something it doesn’t normally, well, i’m always in way over my head but there you go. I am posting this here and on to see if anyone can help me with it.×300.jpg

    The first image here is how the site currently works/looks. First it takes the most recent post and features it at the top of the page. Then it goes on to display the next ten or so posts with thumbnails albeit limited to 220 characters or so. It is checking the category then assigning the appropriate image. It does that using the following code:

    <p style="padding-left: 30px;"><strong><?php if (is_category('7') ):<br />
     <img src='<?php bloginfo('template_url');?>/images/cat7.jpg' alt='' /><br />
     <?php } elseif (is_category('8') ):<br />
     <img src='<?php bloginfo('template_url');?>/images/cat8.jpg' alt='' /><br />
     <?php endif; ?></strong></p>

    This is an abbreviation of the full code used as i’m using about 10 diff categories and thumbnails.

    This is all a bit messy to be honest. And now i am using twitter it is becoming crowded with that little bird bless him. I want to restyle the layout of the posts. That can be done simply with some good CSS. What I really want to do though is to change the layout of the tweet posts completely.×300.jpg

    This is where the second image comes into play. This image shows roughly how i’d like to display the Tweet posts and the standard posts. I’m gonna do away with featuring the first post as its not really for me on this site – i hate it actually. You will see though that the layout of the tweetpost is very different from the standard one.

    I’m using twitter tools to sort the tweets and part of what it does is post my tweets as posts but in doing so it creates a title as well as the content. Fair enough – it has to for wordpress. I don’t want it to display the Title ad the content. I want to get rid of the titles for these tweetpots.

    The way i have been thinking of doing it:

    I want to create different templates for each category then create a query in the loop to see which template to use to display the post. The lovely people at have created a great cheat sheet on a PDF (found this via, on the 3rd page is the following code:

    <p style="padding-left: 60px;"><strong><?php<br />
     $post = $wp_query- >post;<br />
     if ( in_category('3') ) {<br />
     include(TEMPLATEPATH . '/cat3.php’);<br />
     } elseif ( in_category('4') ) {<br />
     include(TEMPLATEPATH . '/cat4.php');<br />
     } else {<br />
     include(TEMPLATEPATH . '/cat.php');<br />
     } ? ></strong></p>

    I want to put this code in to my pages so that whenever a tweet or standard post appears that it will display in a nice and pretty fashion. I just don’t have the PHP/WordPress skills to know which bits of code to change. I have been trying but i keep getting errors.

    any ideas?

    If anyone out there with a super-brain cares to crack this one i’d be a very happy boy.
    Questions welcome.

Viewing 1 replies (of 1 total)
  • a little developmenmt from above:

    This is the bit i’m srtuggling with:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h2><a href=”<?php the_permalink() ?>” rel=”bookmark”>
        <?php if( get_post_meta($post->ID, “hpbottom”, true) ): ?>
        <img style=”float:left;margin:0px 10px 0px 0px;width:50px; height:50px;” src=”<?php echo get_post_meta($post->ID, “hpbottom”, true); ?>” width=”150″ height=”150″  alt=”<?php the_title(); ?>” />
        <?php include(TEMPLATEPATH.”/Cat_Thumb_Assign.php”);?>
        <?php endif; ?>
        <?php if (is_category(’28′) ): ?>
        <?php include(TEMPLATEPATH.”/cat_tweet.php”); ?>
        <?php else: ?>
        <?php the_title(); ?></a>
        <div class=”date”>
        <div class=”dateleft”>
        <p><span class=”time”><?php the_time(’F j, Y’); ?></span>
        by <?php the_author_posts_link(); ?> &nbsp;<?php edit_post_link(’(Edit)’, ”, ”); ?>
        Filed under <?php the_category(’, ‘) ?></p>
        <div class=”dateright”>
        <p><span class=”comment”><?php comments_popup_link(’Leave a Comment’, ‘1 Comment’, ‘% Comments’); ?></span></p>
        <?php the_content(__(’Read more’));?><div style=”clear:both;”></div>
        <!– These are the ‘tags’ markup   <div class=”postmeta2″>
        <p><span class=”tags”>Tags: <?php the_tags(”) ?></span></p>
        <div style=”border-bottom:1px dotted #2255AA; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;”></div>
        <?php endif; ?>
        <?php endwhile; else: ?>
        <p><?php _e(’Sorry, no posts matched your criteria.’); ?></p>
        <?php endif; ?>

    I want it to choose a thumbnail depending on the catagory (the thumbnail assigning happens in Cat_Thumb_Assign.php). This I’ve had working no problem. Then it should choose how to display that post dependingon wether its either catagory 28 (a twitter update) or not.

    Can anyone figure this out?

Viewing 1 replies (of 1 total)
  • The topic ‘getting the loop to pick Cat Templates perpost’ is closed to new replies.