Skip to content
PubIndexAPI

WordPress

We have made setting up the API using WordPress as easy as possible.

Getting Started

What you’ll need

To use the Publisher Indexing API with WordPress you will need two things:

  • API key
  • WordPress plugin

API Key

To get an API key you will need to register for an account and purchase a subscription plan.

WordPress Plugin

Once you have a key, download the latest version of the Pub Index API WordPress Plugin from GitHub here.

How to install

Go to the Plugins > Add New page in WordPress, then click the ‘Upload Plugin’ button (see the image below).

WordPress upload plugin button

Upload the plugin .zip file that you downloaded from GitHub, then activate the plugin.

Go to the settings page for the plugin in WordPress via Settings > Pub Index API.

Enter your API key in the API key field, select the post types you want to use with the API, then hit the Save Settings button.

For many smaller publications with a less complex WordPress setup, you may only have to select the post post type.

If you are using other post types - for example if you have a post type for Live Blogs or Web Stories - make sure you select them from the list, otherwise Google will not be notified when you publish/update.

If you are unsure about which post types are being used on your site, it may be a good to speak with your website development team - or you can individually check the feeds to see if they contain content you want to be indexed.

The RSS feeds being used by the API will be displayed under the Feeds in use label after you have made your selection, so you can easily check the feeds after you have selected a post type.

That’s it! Every time you publish a new post or make changes to an existing post, your updates will be instantly pushed to Google via the API.

Advanced: Creating a Custom Plugin

If you want to create your own custom implementation you can easily edit/customise the code in the provided plugin, or create your own completely custom plugin.

The plugin will require the following functionality:

  • Allow users to input their API key, or alternatively use a single API key
  • Allow users to select post types/RSS feeds for indexing
  • Fetch the API when content is published or updated

The following is a more detailed breakdown of the steps our custom plugin takes:

  • Add a settings page: Create a settings page where users can input their API key and select post types to be indexed.
  • Save the API key and selected post types: Store the API key and selected post types in the database, so they can be accessed later. Make sure to sanitize the data before storing it.
  • Display feed URLs: Display a list of feed URLs for the selected post types on the settings page. This helps users understand which content will be indexed.
  • Send data to the API: Create a function that sends the necessary data to the Publisher Indexing API. This function should be triggered when content is published or updated. The data should include the API key and the feed URL.
  • Error handling: Add appropriate error handling to ensure your plugin behaves as expected, even when users input incorrect data or encounter issues.