Support » Themes and Templates » Desperate help with the loop in my custom theme

  • KO im trying to put together my very first theme, but I’m having some trouble with the loop. What I would live is for each post to be wrapped in its own DIV so that i can style them according to the category there in. Ive tries to add <div class="post"id="post-">to my post DIV, but all post still end up in once single DIV called “post”.

    My code is as follows:

    <?php get_header(); ?>
    <div id="networkcontain">
      <div id="networkbar">
      <div id="tphead">
        <a href="/"><h1>Cerebral Black Hole</h1></a>
    <div id="containertp">
     <div id="contentleft" 
    <div class="tf_body">
     <div class="entryContent">
    <div class="post"id="post-<?php the_ID(); ?>">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h2 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h2>
    <div class="date">
    <?php the_time('F j, Y'); ?> &middot; <a href="javascript:window.print()">Print This Article</a>
    <?php the_content(__('Read more'));?><div style="clear:both;"></div>
    <div class="postmeta">Written by <?php the_author(); ?> &middot; Filed Under <?php the_category(', ') ?>&nbsp;<?php edit_post_link('(Edit)', '', ''); ?>Tagged: <?php the_tags('') ?>
    <?php if (function_exists('sharethis_button')) { sharethis_button(); } ?>
    <?php trackback_rdf(); ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>
    <?php get_footer(); ?>
    <?php get_sidebar(); ?>

    Please help as im a bit lost now and dont realy know what is wrong. For an image of what my curent loop is outputting see this link as you can see there is no seperation between the posts. This is a mock-up of what I would like the posts to be like when Im done see how there formatted acording to the category there in – this is why I want each post to be in its own DIV.

    Again please help as I canot continue untill this is sorted out. Many thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You put that div with the id# OUTSIDE of the Loop, so there is no way that WP can retrieve it. Check out the default’s index – you have the solution there.

    thanks mushu I’ve fixed that now thanks and I now have my posts appearing inside there own div, now i would like to style those divs according to the category there in, ideally with the category slug – whats the best way to do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Desperate help with the loop in my custom theme’ is closed to new replies.