Wordpress functions: Displaying page lists
Over the past seven years Wordpress has blossomed into the industry favorite blogging platform and a widely used and powerful CMS. The newly launched version 3 has ironed out a lot of complexities and made it even more robust and flexible for a beginner to dive in. While learning most of the theming and development of Wordpress based sites on-the-job, I have been taking down notes (or building a cheat sheet of my own, if you will) for quick reference. Here’s a round-up of the built-in Wordpress functions that can be used to list pages of a Wordpress site.
Listing all pages
Listing or excluding specific pages by ID
lists pages with IDs 1 and 5.
Similarly to excluding specific pages use:
this lists all pages except the ones that have IDs 2 and 3.
Sorting Pages
By default wp_list_pages list pages alphabetically. The sort_column parameter can be used in addition to sort pages differently. The possible values are post_title (alphabetically – by default), menu_order (by page order), menu_order (by date of page creation), post_modified (by last modified), ID (sort by ID), post_author (by page author ID), post_name (sort alphabetically by post).
The syntax is of the following nature:
Listing pages based on depth
This is useful in case of listing pages that have sub-level pages and you need to list only the first level of the pages but exclude subpages.
The list pages functions are very useful for navigation menu displays. Keep reading discussions on more such built-in Wordpress functions and shortcuts available for various tasks in future blog posts.
Latest posts by Smarajit Dasgupta
- Playing with HTML5 - July 29th, 2011
- CSS Tutorial - June 7th, 2011
- 5 Tips for optimizing and cleaning up CSS - April 8th, 2011
- Introduction to HTML5 input types - April 1st, 2011
- Text level Semantics in HTML5 - March 17th, 2011
