Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i want to make a single page site which has subpages with following structure

about us
team
-member1
-member2
contact

and i want the output to be like

<div class="about-us">
team content
</div>
<div class="team">
team content
    <div class="subpages">
         <div class="member1">
         member1 content
         </div>
         <div class="member12">
         member2 content
         </div>
    </div>
</div>
<div class="contact">
team content
</div>

and this is my loop so far

<?php query_posts(array('post_type'=>page, 'orderby'=>menu_order, 'post_parent' => $thePostID)); ?>

        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

             <?php if ( 0 == $post->post_parent ) { ?>
             <h1><?php the_title(); ?></h1>
             <?php } else { ?>
                 <h3><?php the_title(); ?></h3>
             <?php } ?>
             <h3><?php the_title(); ?></h3>
             <?php the_content(); ?>
        <?php endwhile; endif; ?>

thanks for helping, helmut

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

To me it's very simple, but a bit static.
You can make a new front-page.php with the structure you mentioned. Then first make some pages (i.e.: About us, Members 1, Contact etc.) in your wp-admin. And use the get_page() function to call different page [using their individual ID] into different zone.

Am I right?

share|improve this answer
    
i did not think about that possibility ... you mean a loop for each page with subpage using the spezific id on one page? –  Helmut Jan 23 '13 at 12:24
    
I din't try this before. So, please try and let me know whether it works or not. Look at a simple page.php page HERE which is responsible for showing Pages (NOT Posts). There is no loop or something, just a simple the_post(); function to call the post. Use the simple way I mentioned above to get a specific page content using its ID and then echo the page content using the_post() and the_content(). If it works, then improvise it in your way. :) –  Mayeenul Islam Jan 24 '13 at 8:02
    
Sorry, the page.php code is HERE. Thanks. –  Mayeenul Islam Jan 24 '13 at 8:08
add comment

Now it is tested. I created PAGE (not POST) in admin panel and then used the page's ID here in a front-page.php file (it will override the index.php, but won't create any problem):

        <div class="about-us">
        <?php
       // VERY SIMPLE LOGIC
           $page_data = get_page(9); // page_id will be your Team page's ID (mine was 9)
           echo $page_data->post_content; // simply get the content of the page (without formatting)
        ?>
       </div> <!-- .about-us -->

       <div class="team">
            <?php
            // EXACT IMPLEMENTATION
                $page_data = get_page( 6 ); // page_id will be your Team page's ID (mine was 6)
                echo '<h3>'. $page_data->post_title .'</h3>';       // to echo the page title       
                echo apply_filters('the_content', $page_data->post_content); // this filter will allow formatting from your page
            ?>

            <div class="subpages">
                <div class="member1">
                    <?php
                    // JUST SEE WHAT YOU GOT
                        $page_data = get_page( 7 ); // page_id will be your Team page's ID (mine was 7)
                        var_dump( $page_data ); // var_dump will show you all the things what get_page() has brought to you.
                    ?>
                </div> <!-- .member1 -->
                <div class="member2">
                    Member2 content
                </div> <!-- .member2 -->
            </div> <!-- .subpages -->

       </div> <!-- .team -->

       <div class="contact">
            Contact page content
       </div> <!-- .contact -->

I commented inline. The whole thing is tested as per the code given in Codex. I've already shared that with you. with var_dump() see what it takes for you and improvise it whatever you like. (Thanks to Asadul Islam Sohag for assisting me)

Yap! Code is Poetry!

share|improve this answer
    
thats exact what i was looking for, thanks ... i try to make a more dynamic version of it, if it works, i let you know and post the code. –  Helmut Jan 25 '13 at 12:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.