Skip to content

Meta Box

rogertm edited this page Sep 14, 2023 · 11 revisions

Meta Box

abstract class WASP_Meta_Box

Para crear Meta Boxes o custom fields debemos crear una clase que extendida de WASP_Meta_Box

<?php
class My_Plugin_Custom_Post_Type_Meta_Box extends WASP_Meta_Box
{
	function __construct()
	{
		parent::__construct();
		$this->id				= 'my-post-custom-fields';
		$this->title			= __( 'Custom Fields title', 'text-domain' );
		$this->screen			= 'my-custom-post-type-slug';
		$this->context			= 'advanced';
		$this->priority			= 'default';
		$this->callback_args	= null;
	}

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

		return $fields;
	}
}
new My_Plugin_Custom_Post_Type_Meta_Box;

Referencias

Clone this wiki locally