Combining 2 arrays to fetch posts *and* pages
-
I have these 2 pieces of code that wonderfully do what I like them to do… pull pages and pull posts.
Now don’t get me wrong, that’s a whole heap-o-pullin’ right there, but I need more pullin’… I’d like to pull both posts and pages in one list, as we all know, 2 is better than 1!
// Pull all the pages into an array $options_pages = array(); $options_pages_obj = get_pages('sort_column=post_parent,menu_order'); $options_pages[''] = 'Select a page:'; foreach ($options_pages_obj as $page) { $options_pages[$page->ID] = $page->post_title; } // Pull all the posts into an array $options_posts = array(); $options_posts_obj = get_posts('numberposts=999'); $options_posts[''] = 'Select a post:'; foreach ($options_posts_obj as $post) { $options_posts[$post->ID] = $post->post_title; }
Thanks ??
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- The topic ‘Combining 2 arrays to fetch posts *and* pages’ is closed to new replies.