Fixed NULL error when using wpdb