stuttter/wp-term-meta

此包已被弃用且不再维护。没有建议的替代包。

元数据,用于分类术语

安装: 141

依赖者: 0

建议者: 0

安全: 0

星星: 28

关注者: 1

分支: 6

类型:wordpress-plugin

0.1.4 2015-10-13 20:01 UTC

This package is auto-updated.

Last update: 2020-02-20 01:07:23 UTC


README

元数据,用于分类术语。

WP Term Meta 允许开发者将与分类、标签或任何自定义分类相关的键/值对数据存储在一起。

安装

  • 使用内置的 WordPress 插件安装程序下载并安装。
  • 在管理后台的“插件”区域通过点击“激活”链接来激活。
  • 无需进一步设置或配置。

使用方法

add_term_meta()

/**
 * Add metadata field to a term.
 *
 * @since 0.1.0
 * @param  int     $term_id     Post ID
 * @param  string  $meta_key    Metadata name
 * @param  mixed   $meta_value  Metadata value
 * @param  bool    $unique      Optional, default is false. Whether the same key
 *                              can be duplicated
 *
 * @return bool False for failure. True for success.
 */

delete_term_meta()

/**
 * Remove metadata matching criteria from a term.
 *
 * You can match based on the key, or key and value. Removing based on key and
 * value, will keep from removing duplicate metadata with the same key. It also
 * allows removing all metadata matching key if needed.
 *
 * @since 0.1.0
 *
 * @param  int     $term_id    Term ID
 * @param  string  $meta_key   Metadata name
 * @param  mixed   $meta_value Optional. Metadata value
 *
 * @return bool False for failure. True for success.
 */

delete_term_meta_by_key()

/**
 * Delete everything from term meta matching meta key.
 *
 * @since 0.1.0
 *
 * @param string $term_meta_key Key to search for when deleting.
 *
 * @return bool Whether the term meta key was deleted from the database.
 */

get_term_meta()

/**
 * Retrieve term meta field for a term.
 *
 * @since 0.1.0
 *
 * @param  int     $term_id  Term ID
 * @param  string  $key      The meta key to retrieve
 * @param  bool    $single   Whether to return a single value
 *
 * @return mixed Will be an array if $single is false. Will be value of meta
 *               data field if $single is true
 */

update_term_meta()

/**
 * Update term meta field based on term ID.
 *
 * Use the $prev_value parameter to differentiate between meta fields with the
 * same key and term ID.
 *
 * If the meta field for the term does not exist, it will be added.
 *
 * @since 0.1.0
 *
 * @param  int    $term_id     Term ID
 * @param  string $meta_key    Metadata key
 * @param  mixed  $meta_value  Metadata value
 * @param  mixed  $prev_value  Optional. Previous value to check before removing
 *
 * @return bool False on failure, true if success.
 */

get_terms()

根据 WP_Meta_Query 规范使用 meta_query 参数: http://codex.wordpress.org/Class_Reference/WP_Meta_Query

$terms = get_terms( 'category', array(
        'depth'      => 1,
        'number'     => 100,
        'parent'     => 0,
        'orderby'    => 'order', // Try the "wp-term-order" plugin!
        'order'      => 'ASC',
        'hide_empty' => false,

        // Looky looky!
        'meta_query' => array( array(
                'key' => 'term_thumbnail'
        ) )
) );

常见问题解答

此插件会创建新的数据库表吗?

是的。它在每个激活的网站上创建一个新的 wp_termmeta 数据库表。

此插件会修改现有的数据库表吗?

不会。WordPress 的所有核心数据库表都保持不变。

此插件支持通过元数据查询吗?

是的。它使用 WP_Meta_Query 类来创建必要的 MySQL。您可以通过将 meta_query 参数传递到 get_terms()、通过过滤 get_terms_args 或以其他任何方式与它进行交互。

我在哪里可以获得支持?

WordPress 支持论坛:https://wordpress.org/support/plugin/wp-term-meta/

我可以做出贡献吗?

是的,请!需要分类术语元数据的使用者数量正在快速增长。拥有易于使用的 API 和强大的功能集对于管理复杂的 WordPress 安装至关重要。如果您对此感兴趣,请帮助我们!