WordPress Custom pages

I want to load all my custom pages on front-page by using the function get_template_part(); but whenever I save my code the page loads everything on front-page but is keeps on looping the content over and over and over again on the site.

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

            <?php while (have_posts()) : the_post(); ?>
                <?php get_template_part('templates/header'); ?>
                <?php get_template_part('templates/page-about'); ?>
                <?php get_template_part('templates/page-services'); ?>
                <?php get_template_part('templates/page-portfolio'); ?>
                <?php get_template_part('templates/page-contact'); ?>
                <?php get_template_part('templates/footer'); ?>
            <?php endwhile; ?>

    </main><!-- #main -->
</div><!-- #primary -->

I’m also going to upload it to github https://github.com/brandonpowell/Test-Wordpress-Site/tree/master/danielschriersite

Related posts

Leave a Reply

1 comment

  1. are calling the header in multiples times tries to remove each of the templates

    enter image description here

    also you call in frontpage template

    try using wordpress pages templates

    https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

    <?php
    /**
     * Template Name: Front Page Template
     *
     * @package WordPress
     * @subpackage Twenty_Fourteen
     * @since Twenty Fourteen 1.0
    */
    ?>
    
    <?php while (have_posts()) : the_post(); ?>
                <?php get_template_part('templates/header'); ?>
                <?php get_template_part('templates/page-about'); ?>
                <?php get_template_part('templates/page-services'); ?>
                <?php get_template_part('templates/page-portfolio'); ?>
                <?php get_template_part('templates/page-contact'); ?>
                <?php get_template_part('templates/footer'); ?>
    <?php endwhile; ?>
    

    and the back you change the page template attr from the admin dashboard

    enter image description here

    you can also use is_front_page() function

    <?php if( is_front_page() ) { ?>
    
           <?php get_template_part('templates/header'); ?>
           <?php get_template_part('templates/page-about'); ?>
           <?php get_template_part('templates/page-services'); ?>
           <?php get_template_part('templates/page-portfolio'); ?>
           <?php get_template_part('templates/page-contact'); ?>
           <?php get_template_part('templates/footer'); ?>
    
    <?php } ?>