I'm creating a one page wordpress website, and I need my 'home', 'about', 'portfolio', 'services' and 'contact' pages to all be on my front page. I created the following page template for my front page:
page-home.php:
<?php get_header(); ?>
<div id="primary">
<div id="content">
<?php
$titles = array('home', 'about', 'portfolio', 'services', 'contact');
$ids = array();
foreach($titles as $title) {
$page = get_page_by_title($title);
if($page) {
$ids[] = $page->ID;
}
}
global $wp_query;
$wp_query = new WP_Query(array('post_type' => 'page', 'post__in' => $ids));
?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The problem I have is that the queried pages, $wp_query->posts, aren't ordered by the array of page ids, $ids, that I used to query the pages. How can I sort the $wp_query->posts array against the $ids array?
This is my first question on wordpress.stackexchange.com so if there is a problem with my question, please let me know.
