Retrieve specific child page with query_posts($query)
-
Hello everybody!
I am using WP as a CMS. I have a number pages (the names of student dorms), lets say ‘dorm1′, dorm2’, etc. and each of them has childres pages with THE SAME names/slugs, eg. ‘dorm1/tutoren’, ‘dorm1/sonstiges’, ‘dorm2/tutoren’, ‘dorm2/sonstiges’ , etc.
I want that the dorm pages ‘dorm1’ show the ‘tutoren’ child page, so I tried this, but it doesn’t work.
$post_id = get_post($post->ID); $slug = $post_id->post_name; $query = 'pagename='.$slug.'/tutoren'; query_posts($query);
Where is the error?
Also, I want this to happen only on “mother” pages, not the children. I tried this:if($post->post_parent) { //the above code }
Many thanks for you help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Retrieve specific child page with query_posts($query)’ is closed to new replies.