0

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',
);
query_posts($args);

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.

0

there are two WordPress functions you could try:

http://codex.wordpress.org/Function_Reference/get_page_by_title

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

http://codex.wordpress.org/Function_Reference/get_page_by_path

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 '12 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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