Using Dynamic Data Pulled from a MySQL Table in a WordPress Page

Yes, you can store your data in your own tables in WordPress database. There are few things that you need to take care of:

  1. Make sure your data can’t be really represented using the built-in WordPress content types.
  2. Prefix your tables with WordPress Prefix + your prefix. WordPress table prefix is $wpdb->prefix.
  3. Use the global $wpdb to query your custom tables, don’t make a new connection.

Now to answer your questions:

  1. Yes, it is okay to store data in custom database tables. It won’t conflict if you prefix your table names.
  2. There are many places to put your PHP code. But don’t put your PHP code in the HTML editor.

    i) You can create your own plugin and for that you can put the code in plugin file which can be stored in wp-content/plugins/ directory.

    ii) You can write your code in your theme’s functions.php file.

  3. You don’t need a plugin to query tables in WordPress. Just read about $wpdb.

Leave a Comment