What I’m trying to achieve is showing only certain pages in a loop. 3 certain pages, not more, not less.
I’ve tried many things but I just can’t complete it.
<?php
$special_tabs = new WP_Query(array ('post_type'=>'page','post__in'=>array(100,102,104)))
?>
What this does, from what I understand, is that it shows an array of pages and then includes those ID’s there as well.
<?php
$special_tabs = new WP_Query('page_id=100');
?>
And this shows only ONE certain page, it doesn’t support the showing of array of different IDs.
I’m sure I am not the first person to have such specific needs and I’m certain there is a relatively simple way to achieve what I’m trying to achieve, but I just can’t come up with a solution or to find one. Can anybody please help me with this?
Many thanks in advance!
just wondering if it would be better to use something like get_pages() instead of creating a new wp_query()?
using this little piece of code you can generate a list of pages you desire..
if you do a print_r on the $special_tab variable you will get following array
hopefully this is something you can use.. 🙂
just remember to include YOUR PAGE ID’s inside get_pages() include section, instead of the 2,3,4 thats their already…
ref: http://codex.wordpress.org/Function_Reference/get_pages
Here is an answer for 2+ months old question:
You want to show certain pages, so what about to calling WP_Query for each page in a foreach:
Don’t worry for calling the loop many times, it’s effect even can’t be noticed in this scale.