I am currently working on a theme which has two post types – one is the normal “posts” post type, and the other is for portfolio posts – “mytheme_portfolio”.
I am using JetPack’s infinite scroll to render new posts, as follows:
function mytheme_render_infinite_scroll() {
while ( have_posts() ) : the_post();
get_template_part( 'content', 'archive-portfolio' );
endwhile;
}
function mytheme_jetpack_setup() {
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'type' => 'click',
'render' => 'mytheme_render_infinite_scroll',
) );
}
add_action( 'after_setup_theme', 'mytheme_jetpack_setup' );
This is working fine but I am wondering how I can specify different content-
template files to render depending on the which post type’s archive/category/tag page you are currently viewing. As it happens now I am calling content-archive-portfolio.php
when the infinite scroll is triggered, what I would like is to call content-archive-portfolio.php
if portfolio posts are being viewed, but content.php
if the blog is being viewed.
Any help would be greatly appreciated, thanks!
Replace the above
mytheme_render_infinite_scroll
function with this: