Wordpress and the Factual API

This page serves to help you access the Factual API from within your own instance of WordPress. You can use Factual’s PHP driver along with WordPress to access Factual data for use with your site.

Getting Started

What you’ll need

You’ll need three things to get started:

  1. An instance of WordPress
  2. The Factual PHP driver
  3. A Factual API Key
Install the driver
  1. Download the zip archive of the driver from Factual or git clone from https://github.com/Factual/factual-php-driver and then zip archive it yourself.
  2. Go to the plugins page of the Wordpress Manager (/wordpress/wp-admin/plugins.php)
  3. Click Add New
  4. Click Upload
  5. Select the .zip archive of the driver (note: the plug-in manager will ONLY accept .zip files)
  6. Click Activate Plugin
  7. Create a test page, something like this:
<html>
<body>
<?php
/** load factual driver. Make sure the path below matches what you have! */
require_once('./wp-content/plugins/Factual/Factual.php');
$factual = new Factual("YOUR_API_KEY","YOUR_API_SECRET");
$query = new FactualQuery;
$res = $factual->fetch("places-us", $query);
$data = $res->getData();
?>
<h1>Hello. I found a place at:
<?php>
/** print the address of the first place */
print_r($data[0][address]);
?>
</h1>
</body>
</html>

Assuming everything is configured correctly, your new webpage should look like this:

Hello World Results