How to insert data into WordPress database ?

WordPress has its own database. Sometimes we have to insert data in a custom table. You can create a custom table in WordPress database and can insert data into WordPress database.  In this example I have used $wpdb function. Here is simple script to insert data into WordPress database custom table .

<?php /* Template Name: db */
global $wpdb;
‘name’ => $name
) == false) wp_die(‘Database Insertion failed’);
else echo ‘Database insertion successful<p />’;

$wpdb is WordPress function to interact with database., dbtable  is the name if database  table.  In array name is inserted into name column of dbtable table.

  • Author:
  • Published Date:

Leave a Reply