WordPress.org

Ready to get started?Download WordPress

Forums

split loop in multiple column in archive page (1 post)

  1. yashmistrey
    Member
    Posted 2 years ago #

    hi i am using this code to get multiple loop

    there are 4 loops

    1 = 1 post
    2 = 1 post
    3 = 5 posts
    4 = rest of all post

    i want to count post in 3rd loop &
    i want to avoid duplicate posts in 4th loop

    <!--1 first loop-->(count = 1 post)

    <?php
    $count = 1;
    if (have_posts()) : while (have_posts()) : the_post();
    	if($count == 1) : ?>
    <a><?php the_title(); ?></a>

    <!--2 second loop-->(count = 1 post)

    <?php if (have_posts()) : ?>
    <?php $count = 1; ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $count++; ?>
    <?php if ($count == 2) : ?>
    <a class="title_ltst" href="<?php the_permalink(); ?>" title=""><?php the_title(); ?></a>

    <!--3 third loop-->(count = 5 post)

    <?php else : ?>
    <a href="<?php the_permalink(); ?>" title=""><?php the_title(); ?></a>
    <?php endif; ?>
    <?php endwhile; ?>
    
    <?php else : ?>
    <h1>Most Viewed News</h1>
    <?php endif; ?>

    <!--4 loop--> (count = rest of all post)

    <?php else : ?>
    <a href="<?php the_permalink(); ?>" title=""><?php the_title(); ?></a>
    <?php if ( $count == 3 || $count == 5 ) : ?>ssssss
    <?php dt_show_ads('position=Archives&before=<div class="adzone_b clear">&after=</div>&title=्&#2334');?>
    <?php endif; ?>
    
    <?php endif; ?>
    <?php $count++; ?>
    <?php endwhile; ?>
    <?php else : ?>
    	<div class="post">
    	<h2 class="archiveTitle"><?php _e('Sorry, nothing matched your criteria','linepress');?></h2>
    	</div>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic