insert row in wordpress table with wpdb class
Question
I'm working on this little plugin that enables a user to submit a post on my website.
if (!isset($wpdb))
$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$wpdb->insert(
$wpdb->prefix . 'posts',
array(
'post_title' => 'testerrrr',
'post_author' => '1',
'post_content' => 'geen content aja',
'post_status' => 'publish'
)
);
The above code isn't adding a new row to the table. (I also tried with $wpdb->wp_posts) And it doesn't give me an error neither (error reporting is turned on though) Are there maybe other fields that I'm obliged to use in the array, or am I doing something else wrong?
Thanks!
Solution
As TheDeadMedic stated, this can be achieved with wp_inser_post();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow