Skip to content

Term Meta

rogertm edited this page Oct 11, 2023 · 10 revisions

abstract class WASP_Term_Meta

Para agregar custom fields a las taxonomías debemos crear una clase hija de WASP\Taxonomy\Term_Meta.

<?php
use WASP\Taxonomy\Term_Meta;

class My_Plugin_Term_Meta extends Term_Meta
{

	function __construct()
	{
		parent::__construct();
		$this->taxonomy = 'my-custom-taxonomy-slug';
	}

	function fields()
	{
		$fields = array(
			'field_name'	=> array(
				'label'		=> __( 'Title', 'text-domain' ),
				'meta'		=> 'field_name'
			),
			/** more fields here */
		);

		return $fields;
	}
}
new My_Plugin_Term_Meta;

Referencias

Clone this wiki locally