Extracted out WP database calls.