Posted inwordpress / Mysql / Mysqli / php

how to Get Database Table Prefix In WordPress?

Today, We want to share with you what is the prefix of wordpress tables by default.In this post we will show you get wordpress table prefix, hear for $wpdb->prefix we will give you demo and example for implement.In this post, we will learn about How To Get Last Insert Id In wpdb WordPress? with an example.

Get Database Table Prefix In WordPress

here you can get table prefix in WordPress

prefix . "posts";
        return $table_prefix;
    }
    // echo get_table_prefix();
?>
/**
 * WordPress Database Table prefix.
 */
$table_prefix  = 'pakainfo_';
// WebSite 2 prefix
pakainfo_2_

// WebSite 3 prefix
pakainfo_3_
function code_function()
{
    global $wpdb;
}
global $wpdb;

// Current & Active web site prefix
echo $wpdb->prefix;
global $wpdb;

// Results pakainfo_2_
echo $wpdb->prefix;

use another main property available in the gloabl $wpdb class defined as $wpdb->base_prefix.

global $wpdb;

// current & Active site prefix
echo $wpdb->prefix;

// main on root file wp-config.php defined prefix
echo $wpdb->base_prefix;

By default the WordPress database table prefix is wp_, you can change this prefix in the main db or some settings like as a wp-config.php. To change the database table prefix add a variable of $table_prefix to the wp-config.php file.

global $wpdb;

$my_table_name = $wpdb->prefix . 'my_table';
var_dump( $my_table_name );

I hope you get an idea about Retrieving and displaying data from WordPress database Table prefix.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype