What files are needed to get wpdb running separately? (2 posts)

  1. nordy
    Posted 2 years ago #

    What files are needed to get wpdb running separately outside of wordpress. I moved wp-db.php and wp-config.php and the thing works ok, but I guess it's missing something more.

    I cannot do queries like $user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users" ); The $wpdb->users part appears blank.

    What other files does wpdb rely on?

  2. bcworkz
    Posted 2 years ago #

    You cannot load WP files piecemeal and expect things to work properly. If your task does not require theme support, you could define SHORTINIT as true before wp-settings.php is loaded to get basic functionality.

    To determine the files needed for SHORTINIT, trace through all the include and related lines starting with wp-load.php until you hit if ( SHORTINIT ) return false; in wp-settings.php.

Topic Closed

This topic has been closed to new replies.

About this Topic