Spiff Up Your WordPress Site with the Jetpack Plug-In
- Setting Up Infinite Scroll
- Setting Up Single Sign On
- Using the Jetpack Mobile Theme
- That's It!
It's easy to give your WordPress site more than just basic functionality. The WordPress Jetpack plug-in provides modules that free up movement on the page, let users sign in with a single WordPress login, and enable compatibility across multiple device types.
Setting Up Infinite Scroll
Sites like Tumblr and Facebook don't bother with such pesky things as page breaks—you can scroll forever (or until you run out of content). To set up your WordPress site to do this takes just a few code modifications.
First, you'll need to add support for Infinite Scroll to your theme:
- Open your theme in an FTP client.
- Open the functions.php file.
- Add the following code (see Figure 1):
- Save your newly revised functions.php file.
/* Add Support for Infinite Scroll */ add_theme_support( 'infinite-scroll', array( 'type' => 'scroll', 'footer_widgets' => false, 'container' => 'content', 'wrapper' => true, 'render' => false, 'posts_per_page' => false, ) );
Figure 1 Add this code snippet to your functions.php file to provide support for Infinite Scroll.
Now you need to activate Infinite Scroll:
- In your WordPress admin section, click Jetpack.
- Find the Infinite Scroll Jetpack widget and click Activate (see Figure 2).
Figure 2 Click Activate to start the Infinite Scroll module.
Now you need to create a new Template Part:
- Open your theme in an FTP client.
- Inside your main theme folder, create a new file called content.php (see Figure 3).
Figure 3 Create a new file where your post generation code will reside.
Next, find the post generation code in the WordPress loop and replace it with your new Template Part so that the Infinite Scroll code can work. Here's how:
- Open the index.php file in your FTP client.
- Find the post generation code (see Figure 4). It will be between the start and end tags for the WordPress loop:
- Copy the post generation code and paste it into your new content.php file.
- Go back to your index.php file and replace the post generation code with the following code, which will load your new Template Part (see Figure 5):
- Save your changes.
<?php while(have_posts()) : the_post(); **code for creating posts** endwhile; ?>
Figure 4 Copy the portion of the WordPress loop that generates a post and paste it into your new file.
get_template_part( 'content', get_post_format() );
Figure 5 Replace the portion of the WordPress loop that generates a post with the call to load your content.php file.
Your site now supports Infinite Scroll!