Using Infinite Scroll with Custom Theme
-
Hi All,
I am trying to use the infinite scroll functionality from the Jetpack plugin but I am having a little trouble. I am using the blankslate theme with some custom post loop code.
Here is the code in my functions.php file:
function custom_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'footer' => 'footer', 'render' => 'custom_infinite_scroll_render', 'posts_per_page' => 6, ) ); } add_action( 'after_setup_theme', 'custom_infinite_scroll_init' ); function custom_infinite_scroll_render(){ while ( have_posts() ) : the_post(); get_template_part( 'entry' ); comments_template(); endwhile; }
Here is the code in my index.php file:
<section id="content" role="main"> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'entry' ); ?> <?php comments_template(); ?> <?php endwhile; endif; ?> <?php get_template_part( 'nav-below' ); ?> </section>
Here is the code in my entry.php file:
<?php if (is_singular()): ?> <a class="breadcrumb-link" href="javascript:javascript:history.go(-1)" title="Back to the blog">← Back to more posts</a> <?php endif; ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if (!is_singular()): ?> <div class="post-image-wrapper"> <?php if (has_post_thumbnail()): ?> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-list-thumb'); ?></a> <?php else: ?> <a href="<?php the_permalink(); ?>"><?php echo ''; ?></a> <?php endif; ?> </div> <div class="post-caption"> <h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div class="post-author"> <?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?> <div class="author-name"><?php the_author_posts_link(); ?></div> <div class="author-meta"><?php echo 'from '; ?><strong><?php the_author_meta( 'user_company', get_the_author_meta( 'ID' )); ?></strong></div> </div> </div> <?php elseif (is_singular()): ?> <header> <?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } ?><?php the_title(); ?><?php if ( is_singular() ) { echo '</h1>'; } ?> <span class="entry-date"><?php echo 'Posted on '; ?><?php the_time( get_option( 'date_format' ) ); ?><?php echo '.'; ?></span> </header> <?php get_template_part( 'entry-content' ); ?> <?php get_template_part( 'entry-footer' ); ?> <?php if ( ! post_password_required() ) comments_template( '', true ); ?> <?php endif; ?> </article>
I would appreciate any help I can get with this as it is very important that it is working before we launch.
Best Regards.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Using Infinite Scroll with Custom Theme’ is closed to new replies.