无法在mysql中创建外键(Wordpress)

I used following query to create a table, but it returns error about foreign key:

$sql = "CREATE TABLE $table_name (
        id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
        supervisor char(30) NOT NULL,
        customer char(30) NOT NULL,
        order_id int(40) NOT NULL,
        status int(5) NOT NULL,
        amount int(40) DEFAULT 0,
        FOREIGN KEY (order_id) REFERENCES wp_post(ID), 
    ) $charset_collate;";

Error:

20-Sep-2015 12:12:36] خطای You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ID') ON DELETE CASCADE
    ) DEFAULT CHARACTER SET utf8' at line 8 در پایگاه‌داده وردپرس برای دستور CREATE TABLE wp_Arvand_Marketing (
        id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
        supervisor char(30) NOT NULL,
        customer char(30) NOT NULL,
        order_id int(40) NOT NULL,
        status int(5) NOT NULL,
        amount int(40) DEFAULT 0,
        FOREIGN KEY (order_id) REFERENCES post('ID') ON DELETE CASCADE
    ) DEFAULT CHARACTER SET utf8 ساخته شده توسط activate_plugin, do_action('activate_woocommerce-arvandkala/safircod.php'), call_user_func_array, adv_activate_plugins, dbDelta

You meant to use backtique around the ID column name and not single quote; which is essentially making it a string literal rather a column name.

Your foreign key line

 REFERENCES post('ID') ON DELETE CASCADE

It should be

REFERENCES post(`ID`) ON DELETE CASCADE