I am pretty new in WordPress theme development and I have some doubts about the single-php file that show a single post.
I have created this single.php file starting from my index.php file:
Testo Introduttivo Introduction Text
<!-- SEZIONE IN CUI VENGONO VISUALIZZATI I POST DEL BLOG: -->
<section id="blog-posts">
<header class="header-sezione">
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
// Previous/next post navigation.
//twentyfourteen_post_nav();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</header>
<!-- Qui viene visualizzato il singolo articolo -->
</section>
<section id="partnerSlide">
<header class="header-sezione">
<h2>Partner e Sostenitori</h2>
</header>
<div class="row">
<?php
// 'My_Widgtet_Area' area, where the id is called:
if (is_active_sidebar('partner-slide')) : ?>
<div id="widget-sidebar">
<ul>
<?php dynamic_sidebar('partner-slide'); ?>
</ul>
</div><!-- #widget-sidebar .widget-area -->
<?php endif; ?>
</div>
</section>
So I have take the index.php file and I deleted all the content that I do not want to be shown in the post visualization (So I have kept only the skeleton of my index.php file theme)
Then I have add this code to show my post:
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
// Previous/next post navigation.
//twentyfourteen_post_nav();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
It work correctly but I have some problem to understand what the previous code exactly do:
I know that by this line I am refering on The Loop to my clicked post (the post to show):
while ( have_posts() ) : the_post();
The thing that I can't understand is what exactly do when perform this operation:
get_template_part( 'content', get_post_format() );
Reading on the documentation (http://codex.wordpress.org/Function_Reference/get_template_part) it seems to me to understand that it load a predefinied template into my theme (like a code snippet putted into my theme)
I think that this put the code that print my post on the page (the title, under it the author name and the datem under it the post text and finally the category and the add comment link)
In practice is as am I putting the content.php file in the position where I have declared the previous code?
Tnx
Andrea
Is it true?