Content Groups

Documentation in Progress..

Sample:

# add a custom field group to current theme
my_group = current_theme.add_field_group({name: "My Group", slug: "my_group_key"})
# add a custom field group to specific post type
my_group = my_post_type.add_field_group({name: "My Group", slug: "my_group_key"})
# add custom field to specific group
my_group.add_field({name: "Web Site", slug: "web_site"}, {field_key: "url"})

# add custom fields into default group multiple support
current_theme.add_field({"name"=>"Home Slider 3", "slug"=>"home_slider3"}, {field_key: "my_slider", translate: true, multiple: true, default_value: [{"image":"https://camaleon.website/media/132/test_images/screen.shot.2016-05-12.at.6.47.38.pm.png","title":"Slider 1","descr":"This is a sample description"}, {"image":"https://camaleon.website/media/132/test_images/screen.shot.2016-05-12.at.6.47.47.pm.png","title":"Slider 2","descr":"This is a sample description 2"}]})
# set values multiple kind for previous field (field with multiple values support)
current_theme.save_field_value("home_slider3", [{"image":"https://camaleon.website/media/132/test_images/screen.shot.2016-05-12.at.6.47.38.pm.png","title":"Slider 1","descr":"This is a sample description"}, {"image":"https://camaleon.website/media/132/test_images/screen.shot.2016-05-12.at.6.47.47.pm.png","title":"Slider 2","descr":"This is a sample description 2"}])
# set single value (for no multiple support)
current_theme.save_field_value("home_slider3", 'Single Value')

# add a custom field no multiple with value for current theme (one line)
current_theme.add_field({"name"=>"Home Slider 3", "slug"=>"home_slider3"}, {field_key: "my_slider", translate: true, multiple: false, default_value: 'default value'}) # for fields no multiple

# add a custom field with multiple support and set values for current theme (one line)
current_theme.add_field({"name"=>"Home Slider 3", "slug"=>"home_slider3"}, {field_key: "my_slider", translate: true, multiple: true, default_values: [{"image":"https://camaleon.website/media/132/test_images/screen.shot.2016-05-12.at.6.47.38.pm.png","title":"Slider 1","descr":"This is a sample description"}, {"image":"https://camaleon.website/media/132/test_images/screen.shot.2016-05-12.at.6.47.47.pm.png","title":"Slider 2","descr":"This is a sample description 2"}]})
Created at: 19 Nov 08:19 | Updated at: 12 May 19:23