Skip to content

Instantly share code, notes, and snippets.

@mizner
Created January 3, 2019 19:48
Show Gist options
  • Save mizner/fcc588eee8bc20975971ceb01626d86a to your computer and use it in GitHub Desktop.
Save mizner/fcc588eee8bc20975971ceb01626d86a to your computer and use it in GitHub Desktop.
custom-metadata example
<?php
namespace Pyxl\One\Models\FieldGroups;
use Pyxl\One\Models\PostTypes\Property as CPT;
class Property {
public static function init() {
$class = new self;
add_action( 'custom_metadata_manager_init_metadata', [ $class, 'register' ] );
}
public function register() {
x_add_metadata_group(
'pyxl_property_fields',
CPT::SLUG,
array(
'label' => 'Group for Property',
'description' => "Here's a group with a description!",
)
);
// adds a text field to the first group
// See wp-content/plugins/custom-metadata/custom_metadata.php
x_add_metadata_field(
'x_fieldName1',
CPT::SLUG,
array(
'group' => 'pyxl_property_fields', // the group name
'label' => 'Text Field', // field label
'field_type' => 'text', // text, checkbox, radio, select, image
'description' => 'This is field #1. It\'s a simple text field.', // description for the field
'placeholder' => '',
'display_column' => true, // show this field in the column listings
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment