colosso
colosso

Reputation: 2525

Get page content in custom template format

I try to set up a single page in wordpress. I have a page Home with a cutom page tempate main.php. The Main page should contain multiple pages under each other so I loop the specific pages with a WP query:

    $args = array(
    'post_type' => 'page',
    'order' => 'ASC',
    'post__in' => array(
        9,  //intro
        11, // about us
        15  // some other stuff
    ) 
);

$pagequery = new WP_Query( $args );

while ($pagequery->have_posts()) : $pagequery->the_post();

This is working without a flaw to read out the content, title and custom fields. Unfortunately all of these three pages need to be formated pretty heavily so I set up custom templates for those pages aswell (intro.php, about.php and so on...). Getting the content works but getting the content / the page formated in the defined custom template looks impossible to me...

How can I get the page completely formated in the custom template form? Or am I doing somethingn really wrong here?

Upvotes: 0

Views: 784

Answers (1)

Paulo Mora
Paulo Mora

Reputation: 249

why you don't set only 1 page with 3 sections ?

Create only one template and call him on The Main page.

<?php /* Template Name: Main-page */ ?>

<?php get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        /* code here the 3 sections */

    </main><!-- .site-main -->

</div><!-- .content-area -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Upvotes: 1

Related Questions