Archive | WordPress RSS feed for this section

Getting all pages in WordPress

20 May

WordPress provides elegant wp_query class to query and manipulate post. You can use query_posts to query the posts in your blog.  If used with The_Loop and other global variables, it is very powerful function.

Sometimes, instead of posts, you need to query all the pages of your website. WordPress use same table to store posts and pages. It distinguishes posts from page using pagetype attribute. Therefore, if you pass pagetype=page in the query_posts, what you will get is all the pages

query_posts('post_type=page&orderby=ID&order=ASC');

In the above query, I am getting all the pages, ordered ascending by their IDs

Follow

Get every new post delivered to your Inbox.