Skip to content

Instantly share code, notes, and snippets.

@randyjhunt
Created February 27, 2010 06:52
Show Gist options
  • Save randyjhunt/316528 to your computer and use it in GitHub Desktop.
Save randyjhunt/316528 to your computer and use it in GitHub Desktop.
<?php
/*
Template Name: List post links
*/
$querystr = "
SELECT p.* from $wpdb->posts p
WHERE p.post_status = 'publish'
ORDER BY p.post_date DESC
";
$allPosts = $wpdb->get_results($querystr, OBJECT);
?>
<ul>
<?php foreach ($allPosts as $post): ?>
<li style="margin-bottom:18px">
<?php echo $post->post_date; ?> &mdash; <?php echo $post->post_name; ?><br/>
<a href="<?php bloginfo('url'); ?>/<?php echo $post->post_name; ?>"><?php bloginfo('url'); ?>/<?php echo $post->post_name; ?></a><br/>
</li>
<?php endforeach; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment