WordPress.org

Ready to get started?Download WordPress

Forums

Display all post titles (period) on the Archives page (2 posts)

  1. harrylove
    Member
    Posted 8 years ago #

    I want the archives page to display every post title I've ever written in reverse chronological order. Not by category, not by date. Just one long list of every post title, each one permalinked, of course.

    I know how to alter the template to display titles and links. What I don't know how to do is change the query. It's currently returning every page title, presumably because is_page is true.

    Can you help?

  2. harrylove
    Member
    Posted 8 years ago #

    Got it.

    <?php
    global $wpdb;
    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC");?>
    <?php if (have_posts()) : ?>

    <ul>
    <?php foreach($posts as $post) :
    setup_postdata($post); ?>

    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <small><?php the_time('l, F jS, Y') ?></small></li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic