I am creating one page wordpress theme - i am new to wordpress dev. The one page website have sections which represents pages. So every section on front page is page created via admin panel.
There is page.php and page-home.
Front-page needs to display all pages as a sections.
So I started with loop inside front-page.php:
<?php get_header(); ?>
<?php
$query = new WP_Query('pagename=home');
if ( $query->have_posts () ) : while ( $query->have_posts() ) : $query->the_post();
get_template_part("page-home");
endwhile; endif;
wp_reset_postdata();
?>
<?php get_footer(); ?>
First problem is: get_template_part not display the_content() from page-home.php, only displays html markup.
Here is the page-home.php
<?php
/*
Template Name: Home
*/
?>
<?php get_header(); ?>
<section id="first_section">
<img class="jumbo wow bounceInDown animated" data-wow-delay="2s" src="<?php echo get_template_directory_uri(); ?>/images/jumbo-illustration.png" alt="Webdesigner and Developer" />
<div class="tagline-wrapper wow bounceInLeft animated" data-wow-delay="2.5s">
<!-- IF the_content() is placed here, it displays the content on front-page -->
<h3 class="tagline"><?php the_content(); ?></h3>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3 class="tagline"><?php the_content(); ?></h3>
<?php endwhile; ?>
</div>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</section>
<?php get_footer(); ?>
Notice <h3 class="tagline"><?php the_content(); ?></h3>
Front page wont render the_content if is in the loop of , but if is before loop it displays normaly.
What I am missing?
Tnx in advance