get_post_format()
Returns the post format of a post. This will usually be called in the the loop, but can be used anywhere if a post ID is provided. and its usually found on the posts pages/blogs.. therefore Its used in a theme when you want to display blog posts.
As you you might know that wp have different posts types. let's just take two of them.
Post (Post Type: 'post')
Page (Post Type: 'page')
The get_post_format()
is used to get the format of a post,(blog Post) if you open your wp dashboard and start a new post or editing existing post you will see different posts formats types
As you can see from the image above, the red highlited part is the post format, that is what you are requesting when u use get_post_format()
wp treats that template as it should display posts, but not pages.
If you want the content of the page you then need to use the_content()
Therefore this
get_template_part( 'content', get_post_format() );
endwhile; endif;
becomes :
get_template_part( 'content', the_content() );
endwhile; endif;
alternatively :
<div class="YourContainer">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="YourContentDiv">
<?php the_content();?>
</div>
<?php endwhile; ?>
<?php else:
echo "no content found";
?>
<?php endif; ?>
</div>
Hope this helps, Goodluck