WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. nordy
    Member
    Posted 9 months 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
    Member
    Posted 9 months 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.

Reply

You must log in to post.

About this Topic

Tags