Ulyssesonline

the tech surfer

  • Home
  • About
  • Archives
You are here: Home / PHP / Jetpack Infinite Scroll

December 19, 2015

Jetpack Infinite Scroll

Just wondering if you have noticed lately. I have implemented WordPress Jetpack plugin’s Infinite Scroll. So, no more pagination. Just endless scroll down. In fact, you can scroll all 1628 posts if you want. I’ve tried other infinite scroll plugins, but none of them work, but Jetpack worked out of the gate. I did have to make some modifications to the footer section. Due to the nature of infinite scroll, you’ll never get to see your original footer, unless you reached the last post, which could take a while depending on the number of posts you have. Jetpack gives you this generic footer which I ended up editing by adding this code in my functions.php file.

/**
 * Customized Jetpack Infinite Scroll.
 */
add_filter( 'infinite_scroll_credit', 'urr_my_footer_text' );
function urr_my_footer_text() {
	$this_year = date('Y');
	$footer_text = 'Copyright © 2003-'.$this_year.'. All rights reserved';
	return $footer_text;
}

/** * Customized Jetpack Infinite Scroll. */ add_filter( 'infinite_scroll_credit', 'urr_my_footer_text' ); function urr_my_footer_text() { $this_year = date('Y'); $footer_text = 'Copyright © 2003-'.$this_year.'. All rights reserved'; return $footer_text; }

The code above resides in functions.php. It inserts a customized footer containing the copyright notice which spans several years and displays the current year using the PHP date function. In addition, I also had to uncomment the underscore pagination from several templates, namely archive.php and search.php so that the navigation links don’t show up in the middle of your infinite scroll page.

<?php //framework_numeric_posts_nav(); ?>
<?php //framework_paging_nav(); ?>

<?php //framework_numeric_posts_nav(); ?> <?php //framework_paging_nav(); ?>

Filed Under: PHP Tagged With: date, infinite scroll, jetpack, year

Subscribe

Tech

  • Is MCN Era Ending?
  • SeTvNow
  • Tesla Production Problems
  • Best SLR Cameras
  • Opera 51

Linux

  • Never Root in Container
  • Zorin OS
  • History of Linux
  • Ubuntu 18.04 LTS
  • BitWarden

Misc

  • EU Getting Rid of DST
  • $15 Digital Ocean Droplet
  • 6 Ways To Cook A Turkey
  • Firefox 54
  • Google Pixel Sold 1 Million Units?

Copyright © 2003 - 2018