What is content.php file that is needed for Jetpack infinite scroll plugin?

I’m currently learning how to use Jetpack infinite scroll plugin, while going through the documentation I came across ‘render’ section:

http://jetpack.me/support/infinite-scroll/

It uses default loop, which I actually need to customise, it also says that if I have content.php file in my template than I’m good to go and can omit render argument. However I don’t know what content.php file is for. As for the loop and the markup of each post, those are defined in my index.php, single.php and page.php files. Could you please explain and give example of what content.php page is, where it should be located and how can it be used.
I’m speculating that its a file where I can paste just my loop and post markup bit, so perhaps I can than somehow include content.php file in my index.php, single.php and page.php files maybe? Not sure.

I did look for this in the codex, but surprisingly couldn’t find explanation of content.php file.

1 Answer
1

There is no standard for a content.php in WordPress, that’s why you cannot find in the Codex. Some themes use it to render the post content.

So instead of …

while ( have_posts() )
{
    the_post();
    ?><li <?php post_class(); ?>>
    <?php
        the_title( '<h2><a href="' . get_permalink() . '">', '</a></h2>' );
        the_excerpt();
        wp_link_pages();
    ?></li>
    <?php
}

… they use …

while ( have_posts() )
{
    the_post();
    get_template_part( 'content', get_post_format() );
    ?></li>
    <?php
}

But you could use any name and it would still work. Jetpack follows a convention from WordPress’ last default themes here; these are using a content.php.

Leave a Comment