• I have query posts on a Page which gets 5 posts per page. Currently it gets 2 posts and displays there content, then gets 3 posts offset by 2 and displays the excerpt only. So 2 big posts and 3 small.

    When I go to the older posts Page 2 the page displays the same layout as the first. What I would like to happen is that any older posts only display the excerpts, so when you are on page 2 -> 5 posts are displayed using the excerpt only.
    Here is my site: https://www.thinkluke.com/blog/

    Here is my code:

    <?php global $more;?>
    <?php add_filter('post_limits', 'my_post_limit'); ?>
    
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    <?php
    	$featured = new WP_Query();
    	$featured->query('posts_per_page=2');
    	while($featured->have_posts()) : $featured->the_post();
    ?>
    <div class="post">
    
    <div class="date">
    <span class="day"><?php the_time('j') ?></span>
    <span class="month"><?php the_time('M') ?></span>
    <span class="year"><?php the_time('Y') ?></span>
    </div>
    <h2 class="blog-title"><a href="<?php the_permalink(); ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <div class="clear"></div>
    
    <?php $more = 0;the_content(''); ?>
    
    <div class="post-btm">
    <a href="<?php the_permalink(); ?>"title="<?php the_title(); ?>" class="blog-more">Read more</a>
    <div class="post-cat"><span>Category:</span> <?php the_category(', '); ?></div>
    </div>
    <div class="clear"></div>
    </div>
    
    <?php if(function_exists('wp_paginate')) {wp_paginate();} ?>
    <?php endwhile; ?>
    
    <?php
    global $myOffset;
    $myOffset = 2;
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('offset='.$myOffset.'&showposts=3'.'&paged='.$paged);
    ?>
    
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    <div class="post">
    
    <div class="date">
    <span class="day"><?php the_time('j') ?></span>
    <span class="month"><?php the_time('M') ?></span>
    <span class="year"><?php the_time('Y') ?></span>
    </div>
    <h2 class="blog-title"><a href="<?php the_permalink(); ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <div class="clear"></div>
    
    <?php the_excerpt(); ?>
    
    <div class="post-btm">
    <a href="<?php the_permalink(); ?>"title="<?php the_title(); ?>" class="blog-more">Read more</a>
    <div class="post-cat"><span>Category:</span> <?php the_category(', '); ?></div>
    </div>
    <div class="clear"></div>
    </div>
    
    <?php endwhile; ?>
        <div class="navigation">
      <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
      <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
    
    </div>
    
    <?php $wp_query = null; $wp_query = $temp;?>
    <?php remove_filter('post_limits', 'my_post_limit'); ?>
    <?php
    function my_post_limit($limit) {
    	global $paged, $myOffset;
    	if (empty($paged)) {
    			$paged = 1;
    	}
    	$postperpage = 3;
    	$pgstrt = ((intval($paged) -1) * $postperpage)+$myOffset . ', ';
    	$limit = 'LIMIT '.$pgstrt.$postperpage;
    	return $limit;
    } //end function post_limit
    ?>

    Getting desperate ??

  • The topic ‘Featured posts, offsets and pagination – custom loop’ is closed to new replies.