Jetpack offers a number of great features for theme developers that help you cut down both development time as well as load times. Most of these features work right out of the box, but you can also get under the hood to apply tweaks and customisations that really take your theme to the next level.
This article introduces you to:
- Speeding up your theme with Photon
- Showcasing posts with Featured Content
- Automatically loading posts with Infinite Scroll
- Instantly applying a Mobile Theme
- Customising CSS
- Providing Sharing functionality
- Integrating Social Links
- Showing similar content with Related Posts
- Additional resources
1. Speeding up your theme with Photon
Photon is a free image CDN offered by Jetpack. As soon as Photon is enabled, it automatically serves the images found in posts and pages from WordPress.com’s speedy servers around the globe.
But did you know that you can use it to save bandwidth and speed up load times for images within your theme, too? You can link to a Photon-ized version of an image by calling the jetpack_photon_url()
function. Its quite straightforward and we’ve put together some step-by-step instructions to make it even easier.
2. Showcasing posts with Featured Content
Featured Content is one of Jetpack’s lesser known features. But it’s a really powerful tool for theme development because you can use it to create a completely custom area in your theme for users to showcase posts. The appearance and placement is completely up to you, the theme author.
Your users can then specify which posts to show in that area simply by selecting a tag of their choice. There’s even an option to hide the tag from post meta and tag clouds.
Whether you are building an image slider on your homepage, or want to allow users to highlight specific posts, Featured Content makes it easier than rolling your own custom functionality. You can see a few examples of the feature in action here.
3. Automatically loading posts with Infinite Scroll
With Infinite Scroll active, users no longer have to click a link to get to the next set of posts on archive pages. Instead, your theme loads the next set of posts automatically into view when the reader approaches the bottom of the page. You’ve probably seen similar functionality on other sites, and thanks to Jetpack, it’s a snap to add it to your theme.
4. Instantly applying a Mobile Theme
Mobile internet usage is growing exponentially and any theme worth its salt should work on mobile devices. That’s why you’ll be happy to know that Jetpack ships with a full Mobile Theme ready-to-go out of the box.
Just use the .mobile-theme
CSS class to style the mobile theme or take things a step further and use jetpack_is_mobile
to target mobile visitors.
That way you can build the best user experience for your theme, no matter what device visitors are using.
Check out this article on customizing Jetpack’s mobile theme to learn more.
5. Customising CSS
If you’ve published a theme before you most likely know that users often want to customize its appearance. Savvy users might create a child theme, but more often than not, users will simply edit your theme’s files directly.
That can get messy when you release a theme update that overwrites users’ modifications. But thanks to Jetpack, a much more user-friendly alternative is available through the Custom CSS feature which also includes a revision history.
After activating the feature, a ‘Custom CSS link’ is added to the Appearance menu in the Dashboard. From there, users can add their own Custom CSS, without touching the theme’s files. They can even use their favorite CSS pre-processer, as support for both SASS and LESS is built right in.
6. Providing Sharing functionality
The Sharing feature allows you to add social media sharing buttons to your theme. There are multiple display options built in and you can opt to use your own custom styles as well.
In this way you can integrate social sharing buttons in your theme, and keep complete control over their appearance. You can even alter the functionality with some jQuery magic. Our friends over at ThemeShaper have a great article with more information about this.
7. Integrating Social Links
Jetpack also makes it easy to include Social Links within your theme. After a user connects their social media accounts through Publicize, you can automatically use links to their accounts in your theme. You can add support with add_theme_support()
and then use the Theme Modifications API to pull the data into your theme.
8. Showing similar content with Related Posts
Related Posts is one of Jetpack’s newer features. When activated, this adds a section to single posts that includes automatically generated links to similar content.
By default the section appears at the bottom of your content, but you can also move it to the top with a filter. In addition users can add a shortcode wherever they want the section to appear.
This means that you can include styling for the Related Posts section in your theme and then users are able to drop in a custom Related Posts section that matches the rest of their site wherever they want.
9. Additional resources
Finally, we’d love to see what you’ve done yourself and what you think of Jetpack. If you have questions, comments or your own tips drop us a comment below! In addition to that, we’re always open to suggestions, so feel free to get in touch. Thanks for flying with Jetpack!
Five Things You Didn’t Know Jetpack Could Do
How well do you think you know Jetpack? Most people know about Stats, Publicize, and Sharing. You may even have your own personal favorite module like Tiled Galleries or Subscriptions. But what about the rest of Jetpack? Here are five things you might not know you can do:
Continue reading → Five Things You Didn’t Know Jetpack Could Do