Answer the question
In order to leave comments, you need to log in
Why is the sql query not working?
I want to add a new field in the wp_posts table when activating the plugin in WordPress.
register_activation_hook( __FILE__, 'wfm_create_field' );
function wfm_create_field(){
global $wpdb;
$query = "ALTER TABLE $wpdb->posts ADD 'wfm_views' INT NOT NULL DEFAULT '0'";
$wpdb->query($query);
}
ALTER TABLE `wp_posts` ADD `wfm_veiws` INT(100) NOT NULL DEFAULT '0' AFTER `comment_count`;
Answer the question
In order to leave comments, you need to log in
Issue resolved.
Changed the entry
Removed quotes from wfm_views.
The only question left is why this code in phpmyadmin does not work?
And I found a solution to this question
. It worked only after I set the default value for post_date post_date_gmt post_date_modified post_date_modified_gmt.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question