Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

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

 
discard

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.