I'm a newbie in English, and in creating my own WordPress theme. So I need your help.
I used Underscores, to help me create my own theme. And I have a problem with my templates:
Underscores use, for example, page.php with a part of the code in the file called template-parts.
The code for page.php is
<div id="template-right-sidebar" class="content-area">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
</div><!-- #template-right-sidebar -->
And the code of content-page.php in the template-parts file is :
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
the_content();
wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', '_-julie-cottet-web' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<?php get_sidebar();?>
<?php if ( get_edit_post_link() ) : ?>
<footer class="entry-footer"></footer><!-- .entry-footer -->
<?php endif; ?>
</article><!-- #post-<?php the_ID(); ?> -->
(Ok, there is more code in reality, but I wanted to make my question more simple.)
The thing is I don't wan't to use the file template-parts. So I want to "copy" the code which is in content-page.php directly in page.php
I must to it wrong, because it is not working. And I don't know why...
What I did :
<div id="template-right-sidebar" class="content-area">
<?php
while ( have_posts() ) : the_post();?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
// AND ALL THE REST OF THE CODE
</article><!-- #post-<?php the_ID(); ?> -->
<?php // If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
</div><!-- #template-right-sidebar -->
What is my mistake ? How can I do that ?
Thanks for reading and for your help !