Hi,
I am having problems with my home page. Hi have a loop on my home page to display a featured post in a bigger size and then the latests post in a smaller size. The point is that my featured post repeats on both sizes. I am trying to use some code as
// FIRST LOOP: display posts 1 thru 5
<?php query_posts('showposts=5'); ?>
<?php $posts = get_posts('numberposts=5&offset=0'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count1 = 0; if ($count1 == "5") { break; } else { ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php $count1++; } ?>
<?php endforeach; ?>
// SECOND LOOP: display posts 6 thru 10
<?php query_posts('showposts=5'); ?>
<?php $posts = get_posts('numberposts=5&offset=5'); foreach ($posts as $post) : start_wp(); ?>
<?php static $count2 = 0; if ($count2 == "5") { break; } else { ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php $count2++; } ?>
<?php endforeach; ?>
But i don't get the idea to work.
My code is:
<?php get_header(); ?>
<?php include (TEMPLATEPATH . "/sidebar.php"); ?>
<?php
if ( $paged == 0 ) {
$offset1 = 0;
$offset2 = 0;
} else {
$off = $paged - 1;
$offset1 = $off * 20 ;
$offset2 = $off * 20 ;
}
?>
<!-- LOOP1 -->
<?php if (have_posts()) : ?>
<?php
$sticky = get_option( "sticky_posts" );
query_posts( array( "post__in" => $sticky, "showposts" => 1 ) );
?>
<?php while (have_posts()) : the_post(); ?>
<div class="post two">
<div class="sepia">
<?php
if ( has_post_thumbnail() ) { ?>
<?php
$imgsrcparam = array(
'alt' => trim(strip_tags( $post->post_excerpt )),
'title' => trim(strip_tags( $post->post_title )),
);
$thumbID = get_the_post_thumbnail( $post->ID, 'two', $imgsrcparam ); ?>
<div class="preview"><a href="<?php the_permalink() ?>"><?php echo "$thumbID"; ?></a></div>
<?php } else {?>
<div class="preview"><a href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_url'); ?>/images/default-thumbnail.jpg" alt="<?php the_title(); ?>" /></a></div>
<?php } ?>
</div><!-- .sepia -->
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<div class="time"><?php the_time('M, d'); ?> · in <?php the_category(','); ?></div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
<!-- #LOOP1 -->
<!-- LOOP2 -->
<?php if (have_posts()) : ?>
<?php query_posts('posts_per_page=20&offset='.$offset2); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post one"<?php echo (is_home())? 'style="border-bottom: none !important;"' : ''; ?>>
<div class="sepia">
<?php
if ( has_post_thumbnail() ) { ?>
<?php
$imgsrcparam = array(
'alt' => trim(strip_tags( $post->post_excerpt )),
'title' => trim(strip_tags( $post->post_title )),
);
$thumbID = get_the_post_thumbnail( $post->ID, 'one', $imgsrcparam ); ?>
<div class="preview"><a href="<?php the_permalink() ?>"><?php echo "$thumbID"; ?></a></div>
<?php } else {?>
<div class="preview"><a href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_url'); ?>/images/default-thumbnail.jpg" alt="<?php the_title(); ?>" /></a></div>
<?php } ?>
</div><!-- .sepia -->
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<div class="time"><?php the_time('M, d'); ?></div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
<!-- #LOOP2 -->
<div style="clear: both;"></div>
<?php include (TEMPLATEPATH . "/bottom.php"); ?>
<?php get_footer(); ?>
Somebody can help me?