Side Notes - Written by Kerry on Tuesday, June 3, 2008 22:15 - 1 Comment

WordPress Custom Loops

I wanted to archive this bit of code as it is a significant look at custom loops, pagination and their use in WordPress Themes. This may lead to a new category on my blog called ‘Code’. It will contain code snippets I find for WordPress Theme & Plugin development. And maybe a bit of PHP thrown in for good measure.

<h3>Recent Articles</h3>
<ul>
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(’showposts=5′.’&paged=’.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link(’&laquo; Previous’) ?></div>
<div class="alignright"><?php next_posts_link(’More &raquo;’) ?></div>
</div>
<?php $wp_query = null; $wp_query = $temp;?>



1 Comment

You can follow responses to this entry through the RSS 2.0 feed. You can leave a response or trackback from your own site.

Ashfame
Jul 7, 2008
02:22 pm
 

Can you please explain what you did here? And your Branded Login Screen plugin produces a fatal err..

Leave a Reply



BasecampHighrise

Comment



 

Design - Aug 31, 2008 10:00 - 1 Comment

Woodie Theme Released

More In Design


News - Aug 15, 2008 15:53 - 0 Comments

Woopra Gets Mention in Practical Webdesign

More In News


How To - Jul 15, 2008 23:59 - 8 Comments

How WordPress 2.6 Broke My Permalink Structure…

More In How To




Login

82 queries. 0.828 seconds.