title: How to implement a single page layout in WordPress
body: <p>I need to make a WordPress template for a client where they define multiple nested (2-level) pages and display them on a single page. The nested pages will be in tabbed sections so users can navigate between those sections by changing tabs. They would also like to have a couple of page displayed normally (on separate pages). To handle that I figured I could just use a different template for pages that go in one page or pages that are separate.</p>
  
  <p>I figured out how to display the pages, but I don't know how to get WordPress to generate the links I want. I want to use the built-in WordPress menus if possible to build the menu with links to anchors (like <code>&lt;a href="#section"&gt;</code> I can't remember the terminology).</p>
  
  <p>I wasn't able to find any example of a single page layout in WordPress except for paid themes (and I'm not paying just to see how someone else did it). I was hoping to use the WordPress built-in menu if possible but if not I guess I could just build the menu myself.</p>
  
  <p>Here is how I display the page:</p>
  
  <pre><code>&lt;?php
  /**
   * Template Name: One Page Template
   */
  
  get_header(); ?&gt;
      &lt;div id="primary"&gt;
          &lt;div id="content" role="main"&gt;
  
              &lt;?php query_posts(array(
                  'post_type' =&gt; 'page',
                  'post_parent' =&gt; 0,
                  'orderby' =&gt; 'menu_order',
                  'order' =&gt; 'ASC'
                  // would also like to check something like 'template' =&gt; 'one-page'
              )); ?&gt;
  
              &lt;?php while (have_posts()) : the_post(); ?&gt;
                  &lt;article class="page" id="&lt;?php echo $post-&gt;post_name; ?&gt;"&gt;
                      &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
  
                      &lt;?php the_content(); ?&gt;
  
                      &lt;?php $sub_pages = new WP_Query(array(
                          'post_type' =&gt; 'page',
                          'post_parent' =&gt; $post-&gt;ID,
                          'orderby' =&gt; 'menu_order',
                          'order' =&gt; 'ASC'
                      ));
                      while ($sub_pages-&gt;have_posts()) : $sub_pages-&gt;the_post(); ?&gt;
                          &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;
  
                          &lt;?php the_content(); ?&gt;
                      &lt;?php endwhile;?&gt;
                  &lt;/article&gt;
              &lt;?php endwhile; // end of the loop. ?&gt;
  
          &lt;/div&gt;&lt;!-- #content --&gt;
      &lt;/div&gt;&lt;!-- #primary --&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>