As long as…
- You use
$wpdb->prefix
(or$wpdb->base_prefix
) to prefix the table - Your table name is someplace public, and easily available for other plugins, themes and end users to use and extend
I would say either setting the table as a property on $wpdb
or using a constant is fine. If you choose to use $wpdb
be aware that another plugin (or theme or whatever) can just overwrite your property in the same way you set it. For that reason, it’s a bit more “safe” to use something like a constant.
Also, always carefully question whether or not you need to add a table.
I tend to use constants, but if I’m doing something like creating a termmeta
table, then I would use a $wpdb
property.
Related Posts:
- Objective Best Practices for Plugin Development? [closed]
- Should I use wpdb prepare?
- How do i best handle custom plugin page actions?
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- Is it mandatory to use $wpdb->prefix in custom tables
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Plugin Form Submission Best Practice
- Best way to abort plugin in case of insufficient PHP version?
- How can I configure Docker for developing and deploying a custom theme?
- What do you think about custom designed plugin/theme options UIs?
- No Error Log File, no debug info
- Where to put third party PHP library?
- Is the new WordPress 3.1 admin bar pluggable and how can I extend it?
- How to use PanelColorSettings in custom Gutenberg block?
- Getting a peer review for my new plugin?
- $wpdb->insert_id
- Optimize shortcode callbacks
- How to integrate a PHP webmail script into the backend of WordPress?
- Using filters and actions for plugin API?
- Check for success of $wpdb->update() correctly
- Is There A Hook To Process The Content Of The Text Widget?
- How to Change the Entire WordPress Admin panel Look and Feel?
- WordPress and multithreading
- How to log plugin errors to plugin error_log file
- Which to use to execute code during the saving of a plugin settings page?
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- Using Primary Color in Plugin Block
- When is it appropriate to put functions on page template vs. functions.php?
- $wpdb->insert is changing a value
- Actions or filters fired when data is saved in a custom table
- Retrieving custom fields with $wpdb->get_results
- Custom theme sufficient or custom plugin neccessary for this feature set?
- When to check if a function exists
- How to create custom home page via plugin?
- Adding callback function for wp_ajax_ has no effect
- Sessions not creating correctly in custom function
- Featured Image not showing in admin
- How to use wp_set_password in a plugin?
- Really simple query giving error in SQL syntax
- Custom Plugin Database relations
- why creating tables using $wpdb is not being executed while installing plugins?
- How to use mysql IN statement with wpdb update method?
- How Can I setup WP CLI on Windows development machine running AMPPS?
- WP_LOCALIZE_SCRIPT doesn’t work
- Using $wpdb object in a widget
- Nuance in adding CPT and TAX to a submenu
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Activation hook not creating table
- Delete a specific item menu when I deactivate my plugin
- Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
- $wpdb -> Batch insert from XML File?
- Get the password key when using the wp_new_user_notification_email filter
- Order properties should not be accessed directly
- How to Download and install plugin database remotely
- How to deal with equal & similar arguments for a function?
- Executing a function upon webhook calling wordpress
- Customizer: widget-synced triggers twice
- WordPress not working on localhost
- Adding functions to hooks from within a class
- how to use hook deleted_user into custom function to delete user from custom table
- Disable The Events Calendar plugin from loading its scripts
- How to insert data to a database table when the field is not yet created?
- include wp-blog-header not working on MAMP
- Applying OO patterns and principles to plugin development
- WordPress is automatically linking plain text email addresses
- Is Using WordPress Supplied WYSIWYG Advisable?
- ServerSideRender and Media Object: attributes passing image data object to php renderer even though it’s not set
- creating custom function to log actions in plugin
- Is it possible to change a term slug before being saved to the database?
- SQL query for custom taxonomy slugs
- Maximum lifetime for nonce
- Clearing caches on plugin uninstall
- How to use a hook to override an update_post_meta call in a plugin?
- Add code inside specific wordpress standard function
- Custom Taxonomy to dropdown box on adminside wordpress
- Link to a admin submenu item using a custom link
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- Change the search results header from plugin
- Dynamic banner for use on external sites
- Adding Meta box to thrid-party plugin
- WordPress plugin tables become corrupt
- How do I store a custom dataset in WordPress to best take advantage of API?
- Client Profiles
- Nothing happens on WordPress Update command
- Fixing plugin for wpdb::prepare
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- How to Implement SAM Broadcaster with WordPress? [closed]
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Custom plugin not appearing
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- Is there any other ways to replicating changes on live from staging without pushing from git
- Can I log the searches that are returning 404 in the DB?
- Developing an IP lookup function using an API
- multiple record insert creating many duplicate records
- Custom fields in the billing address section woocommerce
- Add File field in WooCommerce Box office plugin
- Sticky bar with filter button and product count
- Custom Gutenberg Block ‘Stylized List’ – Incorrect Rendering and Looping of List Items