Write a function that uses $wpdb->prefix as a fallback. Something like this:
function wpse65880_table_with_prefix($table) {
// should define array in config file, rather than hard coding
$my_tables = array("table1", "table2", "table3", "table4");
if (in_array($table, $my_tables)) {
// "qa_" should also be a config file setting
return "qa_" . $table;
}
else return $wpdb->prefix . $table;
}
$table_name = wpse65880_table_with_prefix('post');
$titles = $wpdb->get_results("
SELECT title
FROM $table_name // reflects current prefix
");
Related Posts:
- Creating search form for custom database table
- How can I add data to a custom column in the Users section of the wordpress backend?
- Adding a Table to the wordpress database
- Get Value from Column in Plugin Table [closed]
- The function can not create a table on MariaDB server
- Creating custom database table with crud operation
- dbDelta not creating tables with composite keys
- Saving contact form 7 data into custom Table
- How to make wordpress use a non-wordpress users table?
- Gravity Forms – gform_field_value – query custom table breaks functions.php
- Custom select query two tables by a meta key
- Custom Database Table and foreach
- WordPress search on a custom table
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- What is my error trying to create a new table in the database?
- data retrieval presents last set of data
- Create single{custom}.php with data in table out of wp_posts
- Database custom table issues – incorrect result displayed
- Custom table or form
- How to get value from wp_usermeta table in database?
- When is it OK to create a custom table for a plugin? [duplicate]
- Scaling a WP eCommerce site
- Looking for a lightweight theme using WP3 new tags and features (not 2010) [closed]
- How can I get posts in a subcategory to display on it’s parent categories archive page?
- Creating my own Admin Forms in a WordPress CMS?
- Custom taxonomy: same terms, but for different years
- customize_register with Multiple controls/settings – how to get values?
- Best practices for A/B testing?
- Editing the Number at the end of Page URLs / Editing Page Slugs
- simple wp_insert_post example
- Redirect members to custom page upon logging in through WP admin
- Can I use $wpdb for my custom tables in the WordPress database?
- Integrating MailChimp newsletters as post
- What is WordPress file encoding?
- Importing media medium setting image gallery / image attachments
- Could not create directory. /var/www/html/wp-content/plugins/PLUGIN_NAME/
- WordPress development using Docker – how to share directories? [closed]
- Unique User Account Number + Displayed Via Shortcode
- How can I add Google’s reCaptcha to Divi’s contact form module? [closed]
- How do I copy all “extra” data (menus, widgets, etc) from one theme to another?
- How to add more than one RSS Feed Link for wordpress
- Create default_content layout template based on post id
- Remove ability to Permanently delete an image from the Media Library
- Filter posts by custom taxonomy terms
- Adding a login form that concatenates three fields into a username
- Ability to only view (not edit) other user’s personal profile information
- Fastest way to get the comment and ping total count for a post
- want to create a subcategory.php to manage subcats
- Updates for a private theme
- Is it possible to add a ribbon in the background of h1 on every page?
- How to add textarea field to taxonomy (tag)?
- Contact From 7 Custom Validation Issues
- How to add an extra button on woocommerce shop page and use it to send the product info with image in a mail? [closed]
- Custom comments list, right depth
- Order posts with a custom field but also without
- How to hook up search results page to a back-end page?
- WordPress Custom File Permalink
- WordPress 3.0.1 on IIS 6 Web Server PermaLink Issues
- Widgets won’t save
- Change Notice of Password change email subject?
- Deleting my old WordPress site. – issues
- How to append custom text to the output of ‘categories widget’?
- Centering one product on a single page [closed]
- Remove link from page title
- How to assign a custom post title to be the post ID?
- Creating custom page template
- Which delete query is better with prepare or delete
- How to add page content into another page
- Localhost wordpress access remote db wordpress website
- add_action does not work when instance multiple tab-containers via template-file
- Remove Sidebars from page
- accessing monthly archive from dashboard
- WordPress 3.1.2 Bug: add_theme_support() and video post format registering twice
- Creating a “Delete”-Button for Metadata userspecific
- Change default Video Player without Plugin
- Changing update message from Newspaper child theme
- Custom default settings for WP native Gallery Block
- export and import wordpress customization
- where is admin footer?
- How can i add customisation of text to my theme?
- Can I overwrite custom taxonomy FROM “public” TO “false”
- Trying to customise 2011 Child Theme Background Colour
- the temporary save folder is wrong
- URL issue after setting up Custom Structure in Settings >> Permalinks
- Can I upload my self hosted WordPress website on GitHub as a project? [closed]
- Need to replace some text string on a title
- Custom roles and capabilities media not work right
- How do i edit text that is not in the customization menu
- How do I map two domains to the same wordpress installation?
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Where should I put this custom data?
- how to register / add multiple options into one field in wordpress?
- Custom WP deactivate an email activation link sent to user’s email.
- WordPress Customize panel – accessing the values
- Page template with custom html fields inside a content
- Multiple Customizers
- Background image no more visible in the preview
- I need to make the title of the page dynamic in my custom plugin
- Custom CSS working on home page but not on NEW created PAGE
- Custom Menu (only showing direct cildren) ACF not showing