Skip to content

Instantly share code, notes, and snippets.

@dannyockilson
Created May 15, 2014 18:43
Show Gist options
  • Save dannyockilson/e5fbd38ca4a25c98ef7a to your computer and use it in GitHub Desktop.
Save dannyockilson/e5fbd38ca4a25c98ef7a to your computer and use it in GitHub Desktop.
Set custom Wordpress Options Table
<?php
// Add this into wp-db.php at line 954
if ( isset( $tables['options'] ) && defined( 'CUSTOM_OPTIONS_TABLE' ) )
$tables['options'] = CUSTOM_OPTIONS_TABLE;
?>
<?php
// Add this to your wp config file
define('CUSTOM_OPTIONS_TABLE', 'api_options');
?>
@dannyockilson
Copy link
Author

I know this may seem like a mental thing to do but we had an app that used a custom api to connect to an old site, the site was updated and the new version ran on wordpress. Instead of writting another custom api (that we'd have to update in line with the site) I made a duplicate of the wordpress install, using the same database, copied the wp_options table and renamed it api_options and added this function. Now I can change settings for the api, deactivate plugins and change the theme for the api while still having access to all the content from the main site. I know a multisite install could do this to an extent but this allows the api to be hosted separately from the main site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment