Infinite Scroll – page/2/ repeating same content as page/1/
-
Hi Everyone, I’ve been using this awesome plugin (infinite scroll feature) for well over a year. I had to initally add this to my functions.php to get it to work, but after that everything was great..
function mytheme_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'render' => 'mytheme_infinite_scroll_render', 'footer' => 'footer', 'posts_per_page' => 60, ) ); } add_action( 'init', 'mytheme_infinite_scroll_init' ); function mytheme_infinite_scroll_render() { get_template_part('loop-actions'); get_template_part('loop-content'); }
Today I decided to tweak my loop-content.php to group posts of the same date with another.
original loop-conent.php:
<?php global $loop_view; $ajaxload = get_option('dp_archive_ajaxload'); ?> <div class="loop-content switchable-view <?php echo $loop_view; ?>" data-view="<?php echo $loop_view; ?>" data-ajaxload=<?php echo $ajaxload; ?>> <div class="nag cf"> <?php while (have_posts()) : the_post(); get_template_part('item-video'); endwhile; ?> </div> </div><!-- end .loop-content -->
Current loop-content.php:
<?php global $loop_view; $ajaxload = get_option('dp_archive_ajaxload'); ?> <div class="loop-content switchable-view <?php echo $loop_view; ?>" data-view="<?php echo $loop_view; ?>" data-ajaxload=<?php echo $ajaxload; ?>> <div class="nag cf"> <?php global $wpdb; $splitformat = '%B %d, %Y'; $sql = "SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-3 days')) . "' ORDER BY post_date DESC "; $posts = $wpdb->get_results($sql); $archives = array(); foreach($posts as $post) { $key = strftime($splitformat, strtotime($post->post_date)); $archives[$key][] = $post; } $output = $pre_HTML; foreach($archives as $heading => $posts) { echo '<h3><hr>' . $headingtag . '' . htmlentities($heading) . '</h3>' . $headingtag . '</h3><hr>', "\n"; echo '', "\n"; foreach($posts as $post) { get_template_part('item-video'); } echo '</ul>', "\n\n"; } ?> </div> </div><!-- end .loop-content -->
Unfortunatley when I scroll down to page/2/ it shows the same content as my homepage. I’ve been working on this all day, if anyone can figure it out I will be so very grateful.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Infinite Scroll – page/2/ repeating same content as page/1/’ is closed to new replies.