[wp-hackers] Access custom table using global wpdb not working

Claudio Simeone mrbrog at gmail.com
Wed Jan 11 06:41:01 UTC 2017


2016-12-27 19:17 GMT+01:00 Chris Hearn <chris.hearn01 at ntlworld.com>:

[cut]

> If there some change that only allows "standard" wordpress table names now?

Hi Chris, to add custom tables in the $wpdb object I did in this way

add_action( 'init', 'register_custom_table', 1 );
add_action( 'switch_blog', 'register_custom_table' ); // for multisite

function register_custom_table() {
    global $wpdb;
    $wpdb->custom_tablename = $wpdb->prefix . 'custom_tablename';
}


regards
Claudio


More information about the wp-hackers mailing list