Skip to content
This repository was archived by the owner on Jun 27, 2024. It is now read-only.

Taxonomy

Aleksandr Strikha edited this page Oct 8, 2015 · 2 revisions

namespace: WPKit\Taxonomy

Wrapper class for register_taxonomy.
Register and configure a taxonomy.

Constructor

string $slug - unique key;
string $singular_name - taxonomy title (singular);
array $labels (optional) - array of taxonomy labels;

Example:

$brand_taxonomy = new Taxonomy( 'brand', __( 'Brand' ) );  

This example creates a taxonomy named "Brand".

Methods:

add_post_type( $post_type )

Attach Post Type to taxonomy.

add_custom_field( $key, $title, $field = null )

Add [TaxonomyField] to taxonomy.

Example:

$brand_taxonomy->add_custom_field( 'logo', __('Logo'), 'Image' );  
// get the filed value  
$value = Taxonomy::get_custom_field_value( $term_id, 'logo' );  

// equivalent 
$brand_logo = new TaxonomyField( 'brand', 'logo', __('Logo'), 'Image' );  
$value = TaxonomyField::get( $term_id, 'logo' );  

set_pluralize( $pluralize )

Set automatic pluralization.
Default: true

set_display_in_table( $is_display )

Данный метод указывает будет ли отображаться таксономия в таблице листига post type.
Default: true

Clone this wiki locally