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
- Create tabs in admin options page from custom post type loop
- Create a table with wordpress plugin boilerplate
- Dynamic admin submenu
- Updating plugins asks for FTP information, why? (this is a new one)
- Remove ‘Check Compatibility’ from Plugins menu
- Lock access to plugin options
- Can’t Install Standard Plugins on a Local MAMP installation
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- 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…
- Cannot access my wp-admin after installing Gzip compression [closed]
- Add sub menu page in your plugin
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- Advanced Custom Fields – Disable Users to Edit Custom Fields
- How to insert multiple postmeta values with one query?
- Cannot get wpdb data (Error in a simple fuction) [closed]
- WPDB: Update table
- Plugin settings won’t save changes
- Issue running db create table query from static method
- Full list of registered scripts or styles, but from an admin options page
- Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?
- How to make multiple admin pages for one plugin?
- Locked out of admin panel after installing HC Custom WP-Admin URL [closed]
- How can i force wp-admin to use 2-column dashboard layout? [closed]
- Odd /wp-admin/admin-ajax.php entries showing in Wassup
- How can I modify page content in the admin panel?
- Display Plugin Panels Outside of Admin Areas
- How to display terms and conditions in post area?
- What are the correct permissions so WP doesn’t ask for FTP credentials if installing plugin?
- Is there a plugin for WordPress for creating ‘Accounts’ where all users who belong to that Account can only see Account data? [closed]
- WordPress won’t allow for updates to plugins or WordPress Core
- WordPress Site is Broken, Cannot see wp-admin page [closed]
- WordPress permissions error with admin account
- Why is my WordPress Plugin page requesting my FTP Login Credentials?
- Change the layout of action links under the plugin names
- getting notifications about updates only in the “core” page
- How to remove a CPT Menu from the Root Admin only
- Remove value from array within post meta ajax admin
- Is there a better way of handling AJAX requests in WordPress?
- Redirect Plugins.php to New Plugin Page
- Plugins & backup not working correctly on new Digital Ocean server
- Store plugin page content in wp_options?
- Displaying data from another database
- Get access to WordPress when logged out
- Using $wpdb in a plugin, what sort of data does it return?
- Why are plugin settings not all nested in one place?
- How to access the WordPress DB from a plugin file
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Cannot access WP admin because plugin returns 204
- Install old version of plugin from admin panel?
- WordPress as heavily personalized content management portal, and somewhat like dropbox [closed]
- 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
- How to write to the plugin’s directory?
- I cannot include a file in my plugin settings page
- 404 errors when updating options in admin dashboard
- Error activating certain plugins
- Can’t save changes or modify settings in Dashboard but Pages and Posts are fine
- Need help creating asynchronous data scraper in WordPress
- Change Dashboard URL from wp-admin to wp-admin/index.php
- Trigger jQuery to add events after AJAX-loading table in admin plugin
- ob_end_flush(): failed to send buffer of zlib output compression (0) in external 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
- how to move a plugin-block in Edit Post page back to bottom area?
- force logged in user to stay in the dashboard
- wp_post not working, keeps redirecting to posts page
- WordPress fatal error from php protocol codes
- How to fetch WordPress database values in JavaScript widget
- 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
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function
- $wpdb->delete not working for me
- Can we hide a certain user in WP?
- Calling PHP function with AJAX
- any word search WordPress
- How to properly enqueue jQuery knob on WordPress without conflict?
- WordPress Dashboard add user password not working, etc
- How to securely controlling data without keeping it in postmeta?
- Failed GET Request From admin.php To Fetch .min.js File From Unminifed Directory
- Add custom WordPress admin page with pretty url via code
- Plugin updates, change file permissions on WordPress
- How to find where an image is used by it’s url
- Using id to show item
- Get full URL of WP plugin admin page
- WordPress Admin login redirect to homepage
- WordPress Plugin PHP Not Calling Function
- How to make a plugin api route have permission?
- No result after wpdb->insert
- Admin menu hilighting wrong item for CPT
- Can’t add or delete plugins – but I’m an admin [closed]
- Is admin section completely customizable in terms of styling?
- Store admin page into variable