We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

cori on 04/26/08


Tagged

php wordpress customloop


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

cori


custom loop query example


Published in: PHP 


URL: http://codex.wordpress.org/index.php?title=Template_Tags/query_posts§ion=11#Parameters

the above url has some helpful parameters

  1. <?php $my_query = new WP_Query('cat=3&showposts=1'); ?>
  2.  
  3. <?php if ($my_query->have_posts()) : ?>
  4.  
  5. <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  6.  
  7. <div class="post" id="post-<?php the_ID(); ?>">
  8. <h3><?php the_title(); ?></h3>
  9. <div class="entry">
  10. <?php the_content("Continue reading " . the_title('', '', false)); ?>
  11. </div>
  12. <?php comments_template(); ?>
  13.  
  14. <?php endwhile; ?>
  15.  
  16. <div class="navigation">
  17. <div class="left"><?php previous_post_link('&laquo; Previous Posts'); ?></div>
  18. <div class="right"><?php previous_posts_link('Next Entries &raquo;') ?></div>
  19. </div>
  20.  
  21. <?php else : ?>
  22.  
  23. <h2 class="center">Not Found</h2>
  24. <p class="center">Sorry, but you are looking for something that isn't here.</p>
  25. <?php include (TEMPLATEPATH . "/searchform.php"); ?>
  26.  
  27. <?php endif; ?>

Report this snippet 

You need to login to post a comment.