Awesometoast.com

Fixing stuff and maybe other things.

Displaying WordPress Pages Like Posts

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:
[code lang=”php”]
get_results(“SELECT * FROM $wpdb->posts WHERE post_type = ‘page’ ORDER BY menu_order”, ‘OBJECT’);

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

post_title”; ?>

post_content”; ?>


[/code]

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.

Posted under: Fixing Stuff

0 comments ↓

Leave a Comment