When working with WordPress as a CMS, pages are likely to be used far more often than the typical blogging-focused WP installation. A WordPress as CMS implementation could have hundreds of pages, so one of my favorite tricks for making those pages structured and navigable is to display the subpages of a WordPress page with their meta, such as title, publication date, featured thumbnail, custom fields, excerpts and, of course, permalinks to the subpages.
One example use is on this page of Seattle Photographer Clara Ganey’s portfolio. The portfolio page displays all of its subpages in a multiple column list (another favorite technique of mine) of the subpages’ featured thumbnails with the subpage titles and excerpts showing on hover.
Here’s a peek at the code that generates that portion of the page. Just drop the code necessary to display the meta for each subpage in the commented area below, and a page template with this code in it will display its subpages the way you’d like:
<?php$args = array( 'orderby' => 'menu_order', // Allows users to set order of subpages 'order' => 'ASC', 'post_parent' => $post->ID, 'post_type' => 'page', 'post_status' => 'publish' ); $postslist = get_posts($args); foreach ($postslist as $post) : setup_postdata($post);
?>// Enter code to display for each subpage here. For example, list items // containing featured thumbnails, page titles and permalinks to // the pages.
Have you used a similar technique in a creative way or need help implementing something similar within a theme? Tell me!
Update: Hawaii asks in the comments what some example code for displaying subpages and their meta would look like. Here’s an example that would display a thumbnail linked to the page: