WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Implementing different loop for the fist index page and paged index pages (2 posts)

  1. Tomas Mackevicius
    Member
    Posted 3 years ago #

    Hello, I'm trying to display a little bit different loop for the fist index page and paged index pages. I need offset=2 for the first page, but I don't need it on the subsequent pages. Also I need to exclude one category from the all index pages. At this time I get it work only for the first page. If I would add another if(is_home() && is_paged()) to try to get to the subsequent listing pages, they would not return next posts and would always display the same posts for all pages 2,3,4...etc. My code in the first part of the loop.php is:

    <?php if(is_home()) : ?>
    	<?php /* Setting up initial parameters for the home page */ ?>
    	<?php /* Asigning odd value to a first post of the list */ ?>
    	<?php $odd_or_even = 'post-odd'; ?>
    <?php endif; ?>
    
    <?php /* Excluding main English category */ ?>
    <?php /* use post offset only for the first homepage page */ ?>
    <?php if(is_home() && !is_paged()) : ?>
    	<?php query_posts($query_string . '&cat=-233&offset=2'); ?>
    <?php endif; ?>
    
    <?php while ( have_posts() ) : the_post(); ?>

    Also interesting, that if I would move loop description to the first IF if(is_home()) WP would not render subsequent pages too :-/

    <?php if(is_home()) : ?>
    	<?php /* Setting up initial parameters for the home page */ ?>
    	<?php /* Asigning odd value to a first post of the list */ ?>
    	<?php $odd_or_even = 'post-odd'; ?>
            <?php query_posts($query_string . '&cat=-233&offset=2'); ?>
    <?php endif; ?>

    Thank you for the help!

  2. Tomas Mackevicius
    Member
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic