0

I'm having hard time trying to use teasers post in my wordpress theme (based on 960gs), as you can see here http://img17.imageshack.us/img17/794/schermata20110420a15045.png what I got till now is one "featured" post and three teasers post with thumbnails that will probably be six (so it'll have seven posts displaied in the homepage). The problem is that to do so I have to assign a class "grid_2 alpha" to the teasers post and I don't know how to assign this class to just the first teaser on the left, lefting the other ones with no alpha or omega class and putting the omega class to just the last teaser post (the seventh).

If can help, here's the code I'm using for the loop:

<?php $firstClass = 'firstpost'; ?>
<?php /* Start loop */ ?>
<?php while (have_posts()) : the_post();  ?>

    <?php if (function_exists('yoast_breadcrumb')) { if (is_page() && $post->post_parent) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } } ?>

<div class="post <?php echo $firstClass; ?>">
<?php $firstClass = 'grid_2 alpha'; ?>

<a href="<?php echo get_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true);?>" width="140" height="100" style="padding-bottom:20px;" /></a>

    <h1><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h1>
    <?php the_content(); ?>
    <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>' )); ?>
</div>
<?php endwhile; // End the loop ?>

also I would like to know how I can add some text above the teaser section under the first featured post. Sorry for the too many questions and for my bad english, as you can understand I'm not a developer but I searched for one week and couldn't find anything helpful for my problems. Thanks in advance for any help, I really appreciate it.

Antonio
  • 3
  • 1

1 Answers1

0
<?php $count = 0; ?>
<?php /* Start loop */ ?>
<?php while (have_posts()) : the_post();  ?>
<?php $count++; ?>
<?php if ($count == 1):
        $class = "firstpost';
    elseif ($count == 2):
        $class = "grid_2 alpha";
    elseif ($count == $wp_query->post_count):
        $class = "grid_2 omega";
    else:
        $class = "grid_2";
    endif;
    ?>
    <?php if (function_exists('yoast_breadcrumb')) { if (is_page() && $post->post_parent) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } } ?>

<div class="post <?php echo $class; ?>">


<a href="<?php echo get_permalink(); ?>"><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true);?>" style="padding-bottom:20px;" /></a>

    <h1><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h1>
    <?php the_content(); ?>
    <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>' )); ?>
</div>
<?php endwhile; // End the loop ?>
two7s_clash
  • 5,755
  • 1
  • 27
  • 44
  • Thanks but it doesn't work. Maybe I wasn't clear enough, sorry about that, what I need is to start counting (and then editing) from the second post (the first teaser post) and then put the classes this way: "grid_2 alpha" to the first teaser post and "grid_2 omega" to the last while keeping the other teaser posts with only the "grid_2" class and the first post (the big one) as it already is. When I use this loop instead of the one I have now it just doesn't show anything :( – Antonio Apr 20 '11 at 18:17
  • @Antonio: you want the first post to have the class "firstpost", the second to have the classes "grid_2 alpha", the last to have the classes "grid_2 omega" and the ones in between just to have "grid_2"? Is that right? Your example above only seems to be for the "grid_2" posts. – two7s_clash Apr 20 '11 at 19:41
  • Yes that's exactly what I want, sorry if I didn't explain myself earlier! I don't know why the first loop I posted works but it just does, I have a really really small understand of PHP so I don't really know how to work this out. Many thanks for your help! – Antonio Apr 20 '11 at 19:43
  • Ok, this should do it. But it sounds like there is already a loop above this in your theme... – two7s_clash Apr 20 '11 at 20:05
  • Thanks but it doesn't work, I didn't thought about the other loops, actually it seems that I have five different loop.php files cause I'm working on a theme framework. Do you think this could be the problem why it doesn't accept anything I put in this loop? Thanks. – Antonio Apr 20 '11 at 20:26
  • @Antonio, yes. The loops could be sharing variables. – two7s_clash Apr 20 '11 at 20:59
  • It seems that the problem is just the count as all the loop files doesn't share other variables than the ones I use. – Antonio Apr 20 '11 at 22:02