If you ever need to create a homepage which is build from different pages as sections you can create an index.php page in theme main directory and use the following WordPress get_page/get_post functions which will return WP_Post Object. See example below:

get_page is now deprecated, it uses get_post like an “adapter” in design patterns. So feel free to use get_post instead.

<!-- // yourtheme/index.php -->

<?php get_header(); ?>
  
  <section class="content container first-section" id="for-who">
    
    <?php
      $page_id = 10;
      $page_data = get_page( $page_id );
    ?>

    <h2><?php echo $page_data->post_title; ?></h2>

    <article class="row">
    <?php echo $page_data->post_content; ?>
      <img src="<?php echo get_template_directory_uri(); ?>/content/images/children-lie.jpg" class="img-responsive img-center mobile-hide" alt="">

    </article>

  </section>

  <section class="content container" id="when-to-use">
    
    <?php
      $page_id = 11;
      $page_data = get_page( $page_id );
    ?>
    <h2><?php echo $page_data->post_title; ?></h2>

    <article class="row">

      <div class="col-md-6">

        <img src="<?php echo get_template_directory_uri(); ?>/content/images/girl-learning-math.jpg" class="img-responsive mobile-hide" alt="">

      </div>

      <div class="col-md-6">
        <?php echo $page_data->post_content; ?>
      </div>

    </article>

  </section>


<!-- // and so one ... -->

<?php get_footer(); ?>

https://developer.wordpress.org/reference/functions/get_post/

0
Would love your thoughts, please comment.x
()
x