The WordPress database class and the other various APIs available make it pretty easy to interact with the WordPress database but often times you need to go a step further and create a custom API specific to your plugin’s database tables. Large plugins especially can benefit from having a custom database API as it standardizes common tasks, making them more reliable, more repeatable, and simpler to debug. There used to be a mentality among WordPress plugin developers that you should never use custom tables in your plugin because it wasn’t the “WordPress” way. Let’s start by throwing that attitude out the window. When it comes to storing large amounts of data that does not very closely mimic existing WordPress database schemas, you should absolutely use custom tables. Choosing not to use a custom table will likely cause more harm than good. While it’s possible to store almost anything you want as a custom post type in the wp_posts table, that does not mean you should or that it is even a remotely good idea. Custom tables give us the flexibility store data in the way that we choose, which in turn allows us to build highly efficient data storage and retrieval mechanisms. Let’s compare
Share This