Sometimes, you just wish you could list your WP pages more like posts. I wanted not just a list of them, but with some kind of excerpt. Here’s how I did it:

$thePages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' ORDER BY menu_order", 'OBJECT');

if ($thePages) : foreach ($thePages as $pageData) : setup_postdata($pageData);

  <!-- HTML markup goes here -->
  <h3><?php  echo "$pageData->post_title"; ?></h3>
  <p><?php  echo "$pageData->post_content"; ?></p>         
<?php endforeach; endif; ?>

Naturally, this custom loop is showing the whole page content, and not just a traditional excerpt. I wasn’t able to get excerpts to work, but the full content was just fine for what I was working on. It would not be terribly difficult to use the PHP strlen(); function to limit the post content and simulate an excerpt.

Leave a Reply

Your email address will not be published.