Showing posts with label posts. Show all posts
Showing posts with label posts. Show all posts

Sunday, April 26, 2009

Show all posts in a category in the Archives page

Dump this code in the Archives template before the loop.
<?php
global $wp_query;
  query_posts(
    array_merge(
    array('showposts' => -1),
    array('offset'=>1),
    $wp_query->query
  )
);
?>

Thursday, January 1, 2009

List all titles of WordPress posts in one page

Using this code, you can list all titles of WordPress posts in one page. An example of usage is in an Archives page.


<ul>
<?php
    global $post;
    $myposts = get_posts('numberposts=-1&offset=1');
    foreach($myposts as $post) :
?>
<li>
    <a href="<?php the_permalink(); ?>">
    <?php the_title(); ?>
    </a>
</li>
<?php endforeach; ?>
</ul>

You can change it to n number of posts, by changing -1 in "numberposts=-1" to n.
For tutorial on how to create an Archives page, please read this article.