Showing pages inside of a page

I have a page named “CPD” inside of this page I have a lot of sub-pages in a jQuery UI tabs. I need to load dynamically via WordPress Loop function. But… I just don’t know how can I do it.

What I need is:

Read More

CPD is the first tab and the parent page.
All others like Perfil Organizacional and Diretoria are child pages of “CPD”.

But all this pages load in a single page called page-cpd.php.

So I need to load multiple loops to load directly each page (I can use the ID of each one page) in a single page. And guys… I don’t really know. Below is the code example of the HTML pages in a tab.

<section id="tabs-1">
                    <div class="totalwidth" id="areadeconteudo">
                        <div class="row">
                            <div class="ten columns offset-by-one">
                                <h1>Centro pernambucano <span>de Design</span></h1>
                                <h2 class="subtitulo">
                                    O Centro Pernambucano de Design foi fundado em 2005, a partir de uma demanda identificada pelo SEBRAE/PE, de introduzir ações de design nas Micro e Pequenas Empresas do Estado, como um diferencial competitivo para seus produtos e serviços.
                                </h2>
                            </div>
                        </div>
                        <div class="row">
                            <div class="seven columns offset-by-one">
                                <p>O Centro Pernambucano de Design desenvolve ações de Design Social utilizando ferramentas capazes de otimizar processos produtivos, gerar novos produtos, diagnosticar os fatores locais de cada região, valorizando a identidade sócio-cultural para incremento dos grupos produtivos e consequentemente maior geração de receitas, inclusão social e inserção no mercado.</p>
                                <h2>Design Social, quem sabe faz.</h2>
                                <p>O CPD é  uma organização que busca a auto-sustentabilidade e por isso, todas as ações de design vem acontecendo dentro de um contexto de "Design Social", que desde 2008 vem sendo validado como o principal produto da organização.</p>
                                <p>O Centro Pernambucano de Design se destaca no Brasil como o projeto "que deu certo". E como fatores determinantes para isso vale ressaltar a vocação de Pernambuco na área de design, a real necessidade que o mercado aponta como oportunidade e ao empenho de sua força de trabalho.</p>
                            </div>
                        </div>
                    </div>
                </section>
                <section id="tabs-2">
                    <div class="totalwidth" id="areadeconteudo">
                        <div class="row">
                            <div class="ten columns offset-by-one">
                                <h1>Perfil Organizacional</h1>
                                <h2 class="subtitulo">
                                    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum a faucibus libero. Nulla eget leo vulputate, fermentum diam a, pretium mauris. Cras neque augue, accumsan sit amet commodo ut, pharetra a risus. Morbi tristique dictum purus.
                                </h2>
                            </div>
                        </div>
                        <div class="row">
                            <div class="seven columns offset-by-one">
                                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum a faucibus libero. Nulla eget leo vulputate, fermentum diam a, pretium mauris. Cras neque augue, accumsan sit amet commodo ut, pharetra a risus. Morbi tristique dictum purus, tincidunt euismod lorem convallis in. Maecenas nec ultrices sapien. Mauris est elit, ultricies in consequat et, hendrerit sed sapien. Nullam cursus quam sem, dignissim tristique massa placerat vitae. Pellentesque semper, quam eget ultricies consequat, ligula nibh pharetra libero, in blandit enim erat ut urna. Etiam quis mollis sem. Quisque aliquam, massa vel ornare commodo, tortor lorem aliquet nisi, quis rhoncus odio eros eget sem. Integer vitae mauris rhoncus, porttitor velit vitae, euismod nulla. Aenean facilisis odio ac aliquet sodales. Curabitur nec eleifend nulla, ut placerat purus.</p>

                                <p>Aliquam accumsan, libero nec suscipit pretium, diam nibh dignissim dui, eget mattis lorem enim at dolor. Morbi dictum porta turpis id volutpat. Fusce sodales risus urna, non dignissim elit pulvinar vehicula. Nunc egestas consectetur enim id luctus. Etiam pretium sagittis quam, vitae suscipit turpis pretium vel. Etiam mattis porta gravida. Nulla eu sapien sed nisl porta gravida. Nam ac arcu lacus. Curabitur congue molestie libero, nec pulvinar justo commodo ut. Curabitur non metus eget ante adipiscing vestibulum. Nulla facilisi. Proin tempor risus vel velit suscipit, feugiat semper purus viverra.</p>
                            </div>
                        </div>
                    </div>
                </section>

Each H1 will be the title of subpage. H2 will be a excerpt. And the Lorem Ipsum will be the content. Everything inside of a single page loading pages like /cpd/ (main page) /cpd/perfil-organizacional/ (sub page) /cpd/diretoria/ (sub page).

Related posts

Leave a Reply

2 comments

  1. I have no idea what exactly you need but here is how to loop with WP the way I do it all the time. Build up your arguments in this $args array. (research each line with the codex if you need more info on each) Then create a new WP_Query object. Then loop through your arguments with it.

    $args  = array(
        'posts_per_page'  => 5, //-1 shows all
        //'offset'          => 0, // start from newest
        //'category'        => ,
          'orderby'         => 'post_date',
          'order'           => 'DESC',
        //'include'         => ,
       // 'exclude'         => ,
        //'meta_key'        => ,
       // 'meta_value'      => ,
          'post_type'       => 'page',
        //'post_mime_type'  => ,
        //'post_parent'     => ,
        //'post_status'     => 'publish',
        //'suppress_filters' => true
    );
    $posts = new WP_Query( $args );
    
    if ( $posts -> have_posts()) {
        while ( $posts -> have_posts() ) : $posts->the_post();  {
        //do stuff with the posts returned here
        // echo the_title();
        // the_content();
        // etc
        }
    }
    
  2. I used the plugin Advanced Custom Fields. And “created” everything in the same page. I was trying to do via AJAX loading each page via a “request”. But since it’s was too complicated (and my time is short, I did a “hack”).

    See the code below

    <section id="tabs-1">
                        <div class="totalwidth" id="areadeconteudo">
                            <div class="row">
                                <div class="ten columns offset-by-one">
                                    <h1>Centro pernambucano <span>de Design</span></h1>
                                    <h2 class="subtitulo">
                                        <?php the_field('cpd_sub_texto'); ?>
                                    </h2>
                                </div>
                            </div>
                            <div class="row">
                                <div class="seven columns offset-by-one">
                                    <?php the_field('cpd_texto'); ?>
                                </div>
                            </div>
                        </div>
                    </section>
                    <section id="tabs-2">
                        <div class="totalwidth" id="areadeconteudo">
                            <div class="row">
                                <div class="ten columns offset-by-one">
                                    <h1>Perfil Organizacional</h1>
                                    <h2 class="subtitulo">
                                        <?php the_field('perfil_sub_texto'); ?>
                                    </h2>
                                </div>
                            </div>
                            <div class="row">
                                <div class="seven columns offset-by-one">
                                    <?php the_field('perfil_texto'); ?>
                                </div>
                            </div>
                        </div>
                    </section>
    

    So “the_field” is a function of Advanced Custom Field. Each “the_field” shows something. The “sub_texto” shows a subtitle. The “texto” shows the content.

    Since it was the “easy” way to do, that what I did. LOL.