Introduction to Wordpress Database: wp_postmeta
Just like wp_options and wp_usermeta, wp_postmeta is used to save post related data. These data are generally called custom fields.
One can add custom field from post editor, as shown below:
For example, I have the inserted version in each post using the custom fields.
The structure of this table is as follows:
Field
Type
Null
Key
Default
Extra
meta_id
bigint(20) unsigned
PRI
NULL
auto_increment
post_id
bigint(20) unsigned
IND
0
FK->wp_posts.ID
meta_key
varchar(255)
YES
IND
NULL
meta_value
longtext
YES
NULL
Indexes
Keyname
Type
Cardinality
Field
PRIMARY
PRIMARY
13
meta_ID
post_id
INDEX
15
post_id
meta_key
INDEX
7
meta_key
In the table, the value is saved with meta_key and post id.
These fields can be handled using various functions like add_post_meta(),update_post_meta(),get_post_custom() etc. Please check this URL for more details:
http://codex.wordpress.org/Custom_Fields
Introduction to Wordpress Database: wp_users
Current Version : 2.9.2
Wordpress saves the user details in wp_users table. All the major details like user id, user_login, email address, password (In MD5) are saved in this table.
Below mentioned is the structure of this table:
Field
Type
Null
Key
Default
Extra
ID
bigint(20) unsigned
PRI
NULL
auto_increment
user_login
varchar(60)
IND
user_pass
varchar(64)
user_nicename
varchar(50)
IND
user_email
varchar(100)
user_url
varchar(100)
user_registered
datetime
0000-00-00 00:00:00
user_activation_key
varchar(60)
user_status
int(11)
0
display_name
varchar(250)
Indexes
Keyname
Type
Cardinality
Field
PRIMARY
PRIMARY
1
ID
user_login_key
INDEX
None
user_login
user_nicename
INDEX
None
user_nicename
here, password is MD5 encrypted.
We manually are not supposed to make any entry in this table. However, you can use this function in your template or plugin:
wp_insert_user()
This function requires an array of data to be inserted for the user. Please check more details here …
Introduction to Wordpress Database: wp_usermeta
Current Version: 2.9.2
In general, wordpress saves many user related data. It is difficult to save them in one column in wp_users. Hence Wordpress saves these data in wp_usermeta table. The structure of this table is mentioned below:
Field
Type
Null
Key
Default
Extra
umeta_id
bigint(20) unsigned
PRI
NULL
auto_increment
user_id
bigint(20) unsigned
‘0′
FK->wp_users.ID
meta_key
varchar(255)
Yes
IND
NULL
meta_value
longtext
Yes
IND
NULL
Indexes
Keyname
Type
Cardinality
Field
PRIMARY
PRIMARY
9
umeta_id
user_id
INDEX
None
user_id
meta_key
INDEX
None
meta_key
In this table, we need to add following details:
user_id -> user_id of the user
meta_key -> a unique key for the user data
meta_value -> the actual data to be saved.
Wordpress provides following functions to manage this table:
get_usermeta($userid, $metakey )
$userid
(integer) (required) The ID of the user …
Introduction to Wordpress Database: wp_options
Current Version: 2.9.2
Wp_options tables is used to store wordpress’s default settings, standard options etc. The structure of the table is as follows:
Field
Type
NULL
Key
Default
Extra
option_id
bigint(20) unsigned
PRI Pt1
NULL
auto_increment
blog_id
int(11)
PRI Pt2
0
option_name
varchar(64)
PRI Pt3 & IND
option_value
Longtext
Autoload
varchar(20)
Yes
Indexes
Keyname
Type
Cardinality
Field
PRIMARY
PRIMARY
184
option_id
blog_id
option_name
option_name
UNIQUE
184
option_name
This tables is used by wordpress to save standard options, like blogurl, blog title, description, admin email address, rewrite rules etc.
This table is very useful for plugin and theme developers. A developer can store his own standard options in this table.
How to save data in this …
Image Editor
In WordPress 2.9 whenever you upload an image, you can edit it using the edit image option.
The image editor contains several useful functions such as image cropping, image rotation and image flipping. In addition, you can also undo and redo your actions.
Post Trash Can
Wordpress 2.9 provides a very useful feature, called Post Trash Can. We all are very well aware of this feature and we use it for emails. However, you can use this feature for posts and comments from wordpress 2.9.
wp2-92
The new Trash feature completely replaces the …