wordpress custom loop


/ Published in: PHP
Save to your folder(s)

my wordpress loop with paging support and category,tag filteration


Copy this code and paste it in your HTML
  1. <?php $epaged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  2. $temp = $wp_query;
  3. $wp_query = null;
  4. ?>
  5. <?php $wp_query = new WP_Query('category_name=portfolio&tag=web&showposts=5&paged=' . $epaged);?>
  6. <?php if ($wp_query->have_posts()) : ?>
  7. <section class="itemBlocks">
  8. <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
  9. <article class="iBlock">
  10. <time datetime="<?php the_time('Y-m-d') ?>" class="fs-14" pubdate><?php the_time('F jS, Y') ?></time>
  11. <h1 class="fs-14 color-dark">
  12. <a rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="lnk-item">
  13. <?php the_title(); ?>
  14. </a>
  15. </h1>
  16. <section class="story hidden">
  17. <?php the_content(); ?>
  18. </secion>
  19. </article>
  20. <?php endwhile;?>
  21. <div class="postsPaging">
  22. <?php
  23. next_posts_link( __( '&larr; Older posts', 'twentyten' ) );
  24. previous_posts_link( __( 'Newer posts &rarr;', 'twentyten' ) );
  25. $wp_query = null; $wp_query = $temp;
  26. ?>
  27. </div>
  28. </section>
  29. <?php
  30. endif;
  31. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.