WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a theme in a local machine and migrating it to a production server. To keep things in sync, i'm trying to avoid any queries of specific ID's

On the homepage, i'm trying to query the top 3 pages (by menu_order) from a parent page (NOT the homepage). It works perfectly with the hardcoded ID, but i'm stumped trying to figure out a way to do this without the ID. Seems like I should be able to use the slug, but I can't figure it out.

Here's the code i'm working with:

$args = array(
'post_type' => 'page',
'posts_per_page' => 3,
'post_parent' => '74',
'orderby' => 'menu_order',

So rather than 'post_parent' => '74' I want to use the page slug (e.g. 'books'). Any ideas?

This question seems promising, but as others commented, I'd also like to avoid direct DB queries and the second suggestion didn't work working.

share|improve this question
up vote 0 down vote accepted

there are two WordPress functions you could try:


(as suggested by @t31os in the comments to your quoted link)


if you have already tried them, please describe how these failed to do what you want.

share|improve this answer
$ Thanks Michael. I don't know why I couldn't find get_page_by_title. – Nathan P. Apr 25 '12 at 23:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.