I've got a template that I'm using that has the option of showing either a set of posts on the front page in a featured section or, optionally, display a set of specified pages in the same featured area. I found the code where it displays either/or, however I'm not exactly sure how to combine the two together and get a list of a set of posts AND pages together.
It's my understanding that query_posts() overrides whatever set of items Wordpress displays on the page, so here, depending on what mode the theme is in, it passes in parameters to query_posts() to grab posts of a particular category, or passes in an array of pages:
<div id="slides">
<?php global $ids;
$ids = array();
$featured_cat = get_option('mytemplate_feat_cat');
$featured_num = get_option('mytemplate_featured_num');
if (get_option('mytemplate_use_pages') == 'false') query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));
else {
global $pages_number;
if (get_option('mytemplate_feat_pages') <> '') $featured_num = count(get_option('mytemplate_feat_pages'));
else $featured_num = $pages_number;
query_posts(array
('post_type' => 'page',
'orderby' => 'menu_order',
'order' => 'ASC',
'post__in' => get_option('mytemplate_feat_pages'),
'showposts' => $featured_num
));
} ?>
<!-- Start my loop to display everything-->
<?php if (have_posts()) : while (have_posts()) : the_post();
global $post; ?>
So far, I've made it a little more consise, but can't get over the last little bit of how to combine the parameters to say query_posts(getMyPostsArray().AddList(ohINeedACouplePagesToo())) //Yes, I know this looks like C# or something...I'm not a PHP guy..
here's the code in a little more readable version that's closer to what I want:
$featured_cat = get_option('mytemplate_feat_cat');
//I combined featured_num to get the total number of featured items to display
$featured_num = get_option('mytemplate_featured_num') + count(get_option('mytemplate_feat_pages'));;
query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));
//I think this second line overwrites the first query_posts() :-/
query_posts(array
('post_type' => 'page',
'orderby' => 'menu_order',
'order' => 'ASC',
'post__in' => get_option('mytemplate_feat_pages'),
'showposts' => $featured_num
));