Custom theme index layout not displayed correctly

by Yikko   Last Updated June 12, 2019 19:08 PM

I'm making a custom theme that I'm planning to sell. I'm reading some guides about themes creation, I have already experience with wordpress but this time I want to make a nice theme. I'm facing a problem with the index of my custom theme. I've created some custom template parts that are selectable from the post or page edit section, I've tried during the debug to select the template part and it's selected but will not be applied to the content that are displayed on my homepage. I'm sure that I've made an error with the loop. Here is the code of my index.php file. Can anyone help me with this? I'm not sure if on the index I need to put the loop and if it is needed also inside the template part. Another doubt is about the pages cover. I'm setting a loop on the index that needs to be edited from a code editor, this isn't what I want because users maybe are not able to do that. Is there a way to split it inside a template part that is loaded inside the home? Now my layout is broken and the expected layout will not be loaded correctly (I've added a parallax effect on the featured image, but only the text is loaded in home).

<?php
if( !defined('ABSPATH') ) exit;
get_header();
$page_cover = new WP_Query(array(
  'post_type' => 'page-cover',
  'name' => 'home cover'
));
if( $page_cover->have_posts() ): while( $page_cover->have_posts() ): $page_cover->the_post();
?>
<div class="jumbotron jumbotron-fluid" style="background-image:url('<?php echo the_post_thumbnail_url(); ?>');background-size:100% 100%;" id="cover-wrapper">
  <div class="container">
    <div class="row claime">
      <?php the_content(); ?>
    </div>
  </div>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>

<div class="container-fluid" id="content-wrapper">

  <div class="row">
    <?php if( have_posts() ): ?>
    <?php while( have_posts() ): the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php endif; wp_reset_postdata(); ?>
  </div>
</div>

<!-- footer -->
<?php get_footer(); ?>





Related Questions


Understand post type

Updated November 14, 2016 07:32 AM


Woocommerce - custom post type of checkout page

Updated February 27, 2018 10:08 AM