WordPress custom table install not working properly

I am trying to write a wp plugin. In my project i have 3 php file.

  1. My plugin file
  2. Widget for the plugin
  3. Data installation

I need to install data table on plugin activation.
For that sake I wrote code to create table for my plugin in data installation file. But I am not able to create data table using this file.

Read More

My code for include data installation file and widget file in my plugin file is

define ( 'OTHER_FILES_PATH', plugin_dir_path(__FILE__) );
require_once( OTHER_FILES_PATH.'/data_installation.php' );
require_once( OTHER_FILES_PATH.'/plugin_widget.php' );

My problem is when I put my data installation code in My plugin file it’s working fine but when I put it in separate file (data installation) I am unable to create tables for my plugin.

Please let me know if I am making any mistake. Thanks

Related posts