2

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

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.

  • I had an interesting read about it just a second ago, this post explains it really well ottopress.com/2012/jetpack-and-the-infinite-scroll I do however have one more question if you could answer it, If I don't use standard loop, how can I tell jetpack to use my custom one? For example this is the one I use <?php if (have_posts()) : while(have_posts()) : the_post(); $category = get_the_category(); $postCategory = $category[0]->cat_name; ?> – Ilya Knaup Jun 9 '13 at 17:47
  • Not sure. The docs seem to refer to an element with the ID content, not to a template part. That element would be the container argument. – fuxia Jun 9 '13 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.