Return to Snippet

Revision: 6083
at April 26, 2008 00:12 by cori


Initial Code
<?php $my_query = new WP_Query('cat=3&showposts=1'); ?>

<?php if ($my_query->have_posts()) : ?>

	<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

		<div class="post" id="post-<?php the_ID(); ?>">
			<h3><?php the_title(); ?></h3>
			<div class="entry">
			<?php the_content("Continue reading " . the_title('', '', false)); ?>
		</div>
		<?php comments_template(); ?>		

	<?php endwhile; ?>

	<div class="navigation">
		<div class="left"><?php previous_post_link('&laquo; Previous Posts'); ?></div>
		<div class="right"><?php previous_posts_link('Next Entries &raquo;') ?></div>
	</div>

<?php else : ?>

	<h2 class="center">Not Found</h2>
	<p class="center">Sorry, but you are looking for something that isn't here.</p>
	<?php include (TEMPLATEPATH . "/searchform.php"); ?>

<?php endif; ?>

Initial URL
http://codex.wordpress.org/index.php?title=Template_Tags/query_posts&section=11#Parameters

Initial Description
the above url has some helpful parameters

Initial Title
custom loop query example

Initial Tags
php, wordpress

Initial Language
PHP