• Resolved laemo

    (@laemo)


    Hello,

    I am trying to use multiple loops within my main index template to show first 5 posts as normal, and only show the titles and post information for another 15 posts.

    The code I am using is as below:

    <?php get_header(); ?>
    	<div id="main" class="clearfix">
    		<div id="posts" class="grid_8">
    			<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    			<?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 { ?>
    			<div class="post">
    				<div class="post-image">
    					<?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) : ?>
    						<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'large', false, '' ); ?>
    						<img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo $src[0]; ?>&w=576&h=172&zc=1" border="0" alt="<?php the_title(); ?>" />
    					<?php else : ?>
    						<?php if( get_post_meta( $post->ID, "image_value", true ) ) : ?>
    							<img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image_value", true ); ?>&w=576&h=172&zc=1" border="0" alt="<?php the_title(); ?>" />
    						<?php else : ?>
    							<img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo wp_catch_first_image('l'); ?>&w=576&h=172&zc=1" border="0" alt="<?php the_title(); ?>" />
    						<?php endif; ?>
    					<?php endif; ?>
    				</div>
    				<h1 class="post-title"><a href="<?php the_permalink(); ?>" title="Continue reading &quot;<?php the_title(); ?>&quot;"><?php the_title(); ?></a></h1>
    				<div class="post-meta clearfix">
    					<span class="datetime"><?php the_time('F jS, Y') ?></span>
    					<span class="category"><?php the_category(', ') ?></span>
    					<span class="comment"><?php comments_number('No Comment','1 Comment','% Comments'); ?></span>
    				</div>
    				<div class="post-excerpt"><?php wp_limit_post(200,'.'); ?></div>
    				<span class="post-link"><a href="<?php the_permalink(); ?>" title="Read more about &quot;<?php the_title(); ?>&quot;">Read more &raquo;</a></span>
    			</div>
    
    			<?php $count1++; } ?>
    			<?php endforeach; ?>
    
    			<?php endwhile; endif; ?>
    
    			// Begin posts as list
    
    			<div class="post-small">
    			<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    			<?php query_posts('showposts=15'); ?>
    			<?php $posts = get_posts('numberposts=15&offset=5'); foreach ($posts as $post) : start_wp(); ?>
    			<?php static $count2 = 0; if ($count2 == "15") { break; } else { ?>
    
    			<?php the_date('', '<br />', '<hr />'); ?>
    
    				<h1 class="post-title-small"><a href="<?php the_permalink(); ?>" title="Continue reading &quot;<?php the_title(); ?>&quot;"><?php the_title(); ?></a></h1>
    				<div class="post-meta clearfix">
    					<span class="datetime"><?php if(!function_exists('how_long_ago')){the_time('F jS, Y'); } else { echo how_long_ago(get_the_time('U')); } ?>
    </span>
    					<span class="category"><?php the_category(', ') ?></span>
    					<span class="comment"><?php comments_number('No Comment','1 Comment','% Comments'); ?></span>
    				</div>
    
    			<?php $count2++; } ?>
    			<?php endforeach; ?>
    		</div>
    			<?php endwhile; endif; ?>
    
    			<div class="post-navigation clearfix"><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?></div>
    		</div>
    		<div id="sidebar" class="grid_4">
    			<?php get_sidebar(); ?>
    		</div>
    	</div>
    <?php get_footer(); ?>

    The problem is, when I try to visit page 2 or any other page that displays the posts, it shows me the exact same posts. I am at my wits end to fix this, would really appreciate if someone could help me figure this out.

Viewing 4 replies - 16 through 19 (of 19 total)
  • laemo please start a new thread with a detailed description of what you wish to do.

    I don’t feel i know the answer to that particular question, and i don’t think the question will get noticed under this thread’s heading.

    I’d happily test some code, but my local install is down right now (new configuration i’m still working on – multiple virtual hosts etc..), so until then i’d suggest a fresh topic where you can invite others to offer suggestions.

    Thread Starter laemo

    (@laemo)

    Okay, thanks again. Starting a new thread. ??

    Is it possible to upload the code again? I am searching for the exact same thing for 2 days now… All the codes I find & test are either offset or navigation nothing works together….

    Thanx in advance

    Ditto smoothman, I’m trying to accomplish nearly the exact same thing and would love to take a look at your code.

    Thank you in advance

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Paging with multiple loops in index’ is closed to new replies.