Custom Query To Return Specific Page IDs
-
I’m developing a Golf site where each course has it’s own child page under the course directory page. Each Course page has it’s own meta data assigned through custom fields. Now on the home page I want to show some featured course thumbnails.
I have a working query..But I feel there is a much more efficient way of doing it, then 10 different loops.
Here are two for example, right now I have 10 running, but figured it was a bit much to post all 10, when I can post 2 so you guys get the idea of what I’m doing.
<?php query_posts('page_id=39'); while (have_posts()) : the_post(); $course_thumb = get_post_meta($post->ID, 'course-photo-thumb', true); $course_photo = get_post_meta($post->ID, 'course-photo', true); ?> ---LOOP STUFF, META DATA, IMAGES, ETC.-- <?php endwhile; ?> <?php query_posts('page_id=168'); while (have_posts()) : the_post(); $course_thumb = get_post_meta($post->ID, 'course-photo-thumb', true); $course_photo = get_post_meta($post->ID, 'course-photo', true); ?> ---LOOP STUFF, META DATA, IMAGES, ETC.-- <?php endwhile; ?>
This works fine, but can it be done using only 1 loop? I tried making an array of the page_ids i want to use, and some other things.
Oh and I’m using this plugin: https://blog.ftwr.co.uk/wordpress/query-child-of-page/ to make the querying of sub pages a possibility. Not sure if it even matters now that I’m not using the $child_of parameter. But just thought I’d mention that. At one point I was just returning like 10 courses using the child_of=’course-directory’ parameter, but that didn’t give me total control of which courses to display out of the 10.
Thanks in advance
Mike
- The topic ‘Custom Query To Return Specific Page IDs’ is closed to new replies.