Metadata API

来自WordPress中文文档
跳转至: 导航搜索

wordpress.org.cn

Overview

The Metadata API is a simple and standarized way for retrieving and manipulating metadata of various WordPress object types. Metadata for an object is a represented by a simple key-value pair. Objects may contain multiple metadata entries that share the same key and differ only in their value.

Function Reference

Add/Delete Metadata
Get/Update Metadata

Database Requirements

This function assumes that a dedicated MySQL table exists for the $meta_type you specify. Some desired $meta_types do not come with pre-installed WordPress tables, and so they must be created manually.

Default Meta Tables

Assuming a prefix of wp_, WordPress's included meta tables are:

wp_commentmeta 
Metadata for specific comments.
wp_postmeta 
Metadata for pages, posts, and all other post types.
wp_usermeta 
Metadata for users.

Meta Table Structure

To store data for meta types not included in the above table list, a new table needs to be created. All meta tables require four columns...

meta_id 
BIGINT(20), unsigned, auto_increment, not null, primary key.
object_id 
BIGINT(20), unsigned, not null. Replace object with the singular name of the content type being used. For instance, this column might be named post_id or term_id. Although this column is used like a foreign key, it should not be defined as one.
meta_key 
VARCHAR(255)
meta_value 
LONGTEXT

Source File

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.

Related

模板:Metadata API