Skip to content

Instantly share code, notes, and snippets.

@tyxla
Created February 2, 2016 21:53
Show Gist options
  • Save tyxla/58eba8964bb8e210be66 to your computer and use it in GitHub Desktop.
Save tyxla/58eba8964bb8e210be66 to your computer and use it in GitHub Desktop.
Registering Carbon Fields at the right hook.
<?php
use Carbon_Fields\Container\Container;
use Carbon_Fields\Field\Field;
add_action('carbon_register_fields', 'my_carbon_fields_setup');
function my_carbon_fields_setup() {
Container::make('post_meta', 'test1')
->show_on_post_type('post')
->add_fields(array(
Field::make('complex', 'crb_test1')->add_fields(array(
Field::make('text', 'test1_link_text'),
Field::make('text', 'test1_link'),
)),
));
Container::make('post_meta', 'test2')
->show_on_post_type('post')
->add_fields(array(
Field::make('complex', 'crb_test2')->add_fields(array(
Field::make('text', 'test2_link_text'),
Field::make('text', 'test2_link'),
)),
));
Container::make('post_meta', 'test3')
->show_on_post_type('manga')
->add_fields(array(
Field::make('relationship', 'crb_relationship')
->set_post_type('post')
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment