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.

1 Answer 1


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.

  • $ Thanks Michael. I don't know why I couldn't find get_page_by_title.
    – Nathan P.
    Apr 25, 2012 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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