I’m building a single page website. So multiple pages are shown at once on the frontpage. I order by their position in the primary menu. Everything is fine but to achieve this in a more dynamic manner. I would like to output every page in their own page-template.
Is this possible and how would i achieve this ?
My approach so far –
front-page.php
<?php
if (($locations = get_nav_menu_locations()) && $locations['primary']) {
$menu = wp_get_nav_menu_object($locations['primary']);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$pageID = array();
foreach ($menu_items as $item) {
if ($item->object == 'page')
$pageID[] = $item->object_id;
}
query_posts(array(
'post_type' => 'page',
'post__in' => $pageID,
'posts_per_page' => count($pageID),
'orderby' => 'post__in'
));
}
while (have_posts()): the_post();
//LOOP - INSERT SOLUTION HERE
//Show all pages in their own or default page template (page.php, page-portfolio.php ...)
endwhile;
?>
You can try this:
Remember that you have to remove all the stuff outside the loop from those templates, since you provide this in the calling front-page.php allready. And be sure that the front-page.php never called inside the loop, because this will result in a endless loop.