You will need to restore the database prefix after using it , with something like this
global $wpdb;
$previousPrefix=$wpdb->prefix;
$wpdb->prefix="mainsiteprefix_";
//Database access goes here
$wpdb->prefix=$previousPrefix;
or you can create a new wpdb object like this:
$wpdb2 = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
Related Posts:
- Add menu page issues (permissions & position)
- Is there any way to make myself an admin?
- $wpdb update query in plugin only updating one column
- Mowing site to another domain in simplest way
- Adding a Taxonomy Filter to Admin List for a Custom Post Type?
- to perform the requested action wordpress needs to access your web server. please enter your ftp
- I found this in a plugin. What does it do? is it dangerous?
- Disable /wp-admin/plugin-install.php
- How to eliminate weird 404 errors in wp-admin?
- Can’t install new plugins because of the error “Could not create directory”
- Is There a WordPress Hook to Filter the Edit Posts View?
- Cannot install plugins even though www-data has write permissions
- Reordering themes in admin panel
- Removing an admin page added by a 3rd party plugin. Gravity forms in this example
- Custom admin column disappearing when using Quick Edit [duplicate]
- WordPress admin notice in plugin function
- Using tabs for wordpress plugin
- Getting Custom Post Type content from main-site of a Multisite
- Plugins won’t auto-update on IIS
- Missing argument 2 for wpdb::prepare() Issue
- how to not show plugin in admin area
- How to make a WP admin button/menu similar to Jetpack Notifications?
- Getting “Fatal error: Call to undefined function wp_cache_get() in option.php” after updating a cache plugin [closed]
- How Restrict access to admin dashboard by specific static ip?
- Edits to plugin not taking effect
- Creating Custom Roles for use on a WordPress Multi-site Instance?
- Can’t use the built-in wordpress install/upgrade plugin feature [closed]
- Making menu link open in new tab?
- Weird problems after recovery from security breach
- Why am i getting this error? WordPress database error: [Query was empty]
- How to Sort the Favorite Plugins Screen Alphabetically?
- Hide extra menus from WordPress Dashboard
- ‘wp_login’ action hook not working with wp-login.php file
- plugin ajax to external php file always return null
- 404 Error on Activate / Deactivate Plugin
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- When to call add_filter
- All Users > User List > Update User Meta Field Inline
- Correct way to perform non-cacheable DB query
- How to hide some section in WordPress under Post
- Default WordPress WP Editor removing style tags and html tag
- Polylang : Interverting languages after development [closed]
- Lock access to plugin options
- Can’t Install Standard Plugins on a Local MAMP installation
- Object method calling for global $wpdb in header.php
- Using wpdb without loading all plug-ins via wp-load.php
- Network activating; if ( !current_user_can( ‘manage_options’ ) ) locks me out…
- WPDB: Update table
- How to make multiple admin pages for one plugin?
- WordPress won’t allow for updates to plugins or WordPress Core
- WordPress permissions error with admin account
- Change the layout of action links under the plugin names
- getting notifications about updates only in the “core” page
- Redirect Plugins.php to New Plugin Page
- Store plugin page content in wp_options?
- Why are plugin settings not all nested in one place?
- How to access the WordPress DB from a plugin file
- Edit page header on a custom plugin
- How to hide plugin options for editors via functions.php
- Linked pages from plugin on front can’t see $wpdb
- Error activating certain plugins
- Change Dashboard URL from wp-admin to wp-admin/index.php
- Elementor pro page editing gives error There has been a critical error on this website. Please check your site admin email inbox for instructions
- See which user role / capability is needed to use a plugin
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Calling PHP function with AJAX
- Failed GET Request From admin.php To Fetch .min.js File From Unminifed Directory
- WordPress Admin login redirect to homepage
- How to make a plugin api route have permission?
- Admin login substantially slower on production server
- Permission Issues regarding Plugin updates & FTP transfers
- How can I share my wordpress site with a friend?
- Continous audio play in pages
- Set plugin page as homepage
- WordPress Plugin Install / Update Problem
- Wordress admin page is fetching error You do not have sufficient permissions to access this page.
- Admin page and admin menu. Permissions plugin
- Admin Logged In Notify Globaly
- wp-admin will not redirect to wp-login.php
- Getting 404 page not found error while trying to access add new plugin / themes
- getpost content with all formatting for admin pages
- Plugin (smart archives reloaded) crashed site / no access on admin panel
- Plugin not installing properly, functions being redeclared
- Which filters or actions involve with index page for plugin?
- Ajax in Plugins: returns the whole page
- Gutenberg: Dynamic Block – Show saved data in the editor
- Combining JS files to one script
- How do I add custom fields to the “Edit page” admin screen?
- Get all the related data from WordPress DB
- Mixed content warning on doctype in admin
- Child Plugin Admin Panel
- Ajax in wordpress [duplicate]
- Notifications Bar on home page only
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- List all posts in a particular page [closed]
- How to give access to the particular page in wordpress for specific username/email NOT roles [closed]
- WordPress Plugin and other pages not opening
- warning wp session
- Submitting form to admin-post.php WordPress
- /wp-admin/plugins.php takes ages to load, and then 404s