Is there a way to set singular/plural labels for taxonomy term names?

Let’s says I have a taxonomy called Types. I know I can have a singular name when registering the taxonomy… so I could just set the singular label to Type.

But is there a way to the same/similar to the actual terms inside Type?

Eg.
Term / Plural / Singular
Books -> Book
Movies -> Movie

Will I need a custom field? Or is there a Wp way of doing this?

1 Answer
1

In WordPress 4.4 we will be able to use the long waited term meta so you might use that to store the extra info for your terms.

The Term Meta API calls are:

Add term meta:

Function call:

add_term_meta( $term_id, $meta_key, $meta_value, $unique );

Description:

/**
 * Adds metadata to a term.
 *
 * @since 4.4.0
 *
 * @param int    $term_id    Term ID.
 * @param string $meta_key   Metadata name.
 * @param mixed  $meta_value Metadata value.
 * @param bool   $unique     Optional. Whether to bail if an entry with the same key is found for the term.
 *                           Default false.
 * @return int|WP_Error|bool Meta ID on success. WP_Error when term_id is ambiguous between taxonomies.
 *                           False on failure.
 */

Update term meta:

Function call:

update_term_meta( $term_id, $meta_key, $meta_value, $prev_value );

Description:

/**
 * Updates term metadata.
 *
 * 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 4.4.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 int|WP_Error|bool Meta ID if the key didn't previously exist. True on successful update.
 *                           WP_Error when term_id is ambiguous between taxonomies. False on failure.
 */

Delete term meta:

Function call:

delete_term_meta( $term_id, $meta_key, $meta_value )

Description:

/**
 * Removes metadata matching criteria from a term.
 *
 * @since 4.4.0
 *
 * @param int    $term_id    Term ID.
 * @param string $meta_key   Metadata name.
 * @param mixed  $meta_value Optional. Metadata value. If provided, rows will only be removed that match the value.
 * @return bool True on success, false on failure.
 */

Leave a Comment