How to Use WordPress Jetpack Offline
Note: This post was first published on the Feb 23, 2015.
Jetpack offers a variety of modules to enhance your WordPress site with features like contact forms, infinite scrolling, and shortcodes. These tools can make your self-hosted WordPress website as powerful as sites hosted on WordPress.com. However, a major drawback is that Jetpack typically requires an internet connection and a WordPress.com login.
Usually, you can only utilize these features on a live site. Once you activate the plugin, a persistent banner will appear at the top of your Dashboard.
Want to know how to get it to work offline so you can develop your theme without distractions? Here’s how. Note: Before installing Jetpack, ensure your website is running WordPress 3.8 or later.
Enabling Infinite Scroll for WordPress Themes
On the web, Infinite Scroll is a technique that loads content continuously as users scroll down a page.... Read more
Jetpack 2.2.1
Since version 2.2.1, Jetpack has introduced Development Mode, allowing you to activate features while in development. To enable this mode, add the following line in the wp-config.php file after the WP_DEBUG
line:
define('JETPACK_DEV_DEBUG', true);
If you prefer not to edit wp-config.php or don’t have access to it, you can use the Run Jetpack Locally plugin. This small plugin includes the following line, which essentially acts as an alias for JETPACK_DEV_DEBUG
:
add_filter('jetpack_development_mode', '__return_true');
Next, go to the Jetpack > Settings page. You’ll notice that the banner is gone, and Jetpack is now in Local Development Mode.
Jetpack is now available offline. Several plugins, including Infinite Scroll, should be activated. These plugins can function independently of a connection to the WordPress.com API. However, other features like Photon and Stats will still require the WordPress.com API.
An Alternative Route
If you aren’t satisfied with only some features being enabled, there’s a way to activate all of them while keeping Jetpack running offline.
First, let’s make our local website accessible online to connect to WordPress.com using localtunnel.
Check out our previous tutorial on how to install and set up localtunnel on your computer.
Once installed, run the following command in Terminal to make your local host directory accessible online. If you are using MAMP, the directory is likely located at “/Applications/MAMP/htdocs”.
lt --80
Localtunnel will provide you with an address where you can access the localhost in the browser:
Before accessing the website through the given address, go to phpMyAdmin or a similar app to view your website’s database. Open the website database and navigate to the wp_options
table. Change the website URL in the siteurl
and home
fields to point to localtunnel, like this:
Access and log in to the website through the new address. Now that your website is online, WordPress.com should be able to connect to it.
And there you go, your website is connected to WordPress.com, and you can use all the Jetpack modules.
Reminder: Don’t forget to switch the website address in the wp_options table back afterwards.
What’s Next?
You might be wondering if you need to connect each of your offline websites to WordPress.com individually. The good news is, you don’t have to.
Once you have one website on your localhost connected, you can simply copy the jetpack_option
value to the other websites. Here’s how to do it:
Go to phpMyAdmin. In the wp_options
table of the connected website, copy all the values of the jetpack_option
, like this:
Paste this value into the other websites where Jetpack is activated. Now, as shown below, you can activate and use all the Jetpack modules offline on the other websites you are developing locally.
Remember, this method is intended to help you use Jetpack while testing it against your theme or plugins during development. If your website is live, you should connect it properly.