Using Loops and Pagination in WordPress

Using loops you can show wordpress content.If you want to show the full content for the first two posts and then just the excerpt for the rest then this code is for you.

<?php
      $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
      query_posts("paged=$page&posts_per_page=5"); ?>

	<?php $count = 1; // Sets count to 1 on first output post ?>

		<?php while (have_posts()) : the_post(); ?>

     <?php if ((!is_paged()) && ($count == 1 || $count == 2)){ // THIS STARTS FULL CONTENT IF IS FIRST POST AND NOT PAGED, THE OR OTHER COUNT ALLOWS FOR SHOWING MORE THAN ONE OF THE FULL CONTENT POSTS BEFORE GOING TO EXCERPTS ?>

                    <?php the_content(); ?>

                    <?php } else { // THIS ends FULL CONTENT and SHOWS FOLLOWING POSTS ELSE ?>

                    <?php the_excerpt(); ?>

<?php } $count++; // THIS IS the END of ELSE and sets count one up ?>


	<?php endwhile; ?>
?>
4 replies
  1. BG mail
    BG mail says:

    Pretty element of content. I just stumbled upon your weblog and in accession capital to claim that I get actually loved account your blog posts. Anyway I’ll be subscribing in your feeds and even I fulfillment you access consistently quickly.

    Reply
  2. Dewey Derenzis
    Dewey Derenzis says:

    Thanks for any other fantastic post. The place else may just anyone get that kind of information in such an ideal way of writing? I’ve a presentation subsequent week, and I’m on the look for such info.

    Reply

Trackbacks & Pingbacks

  1. fake oakleys says:

    fake oakleys…

    Using Loops and Pagination in WordPress – WordPress | Joomla | Magento Developer…

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply