Adding Fields Using PHP

Adding fields this way is the best way to do it if you are working in multiple server environments, for example if you have both a test server and a production server.

If you want to add fields using GUI that is also possible, but moving fields from one server to another may be a bit cumbersome then, involving database exports and imports.

Example

This example adds a lot of fields to a field group and then makes that field group available to all posts, and finally it makes this the field group the default one for all posts.

12 thoughts on “Adding Fields Using PHP

      1. Jo

        array(
        ‘slug’ => “my_radiobutton_field_slug”,
        ‘name’ => ‘Test radiobutton’,
        ‘description’ => ‘Radiobutton description’,
        ‘type’ => ‘radiobutton’,
        ‘type_radiobutton_options’ => array(
        array(“value” => “Yes”),
        array(“value” => “No”)
        )
        ),

        This one (example above) doesn’t work for me. nothing appears.

        modification of mine:

        array(
        ‘slug’ => “my_radiobutton_field_slug”,
        ‘name’ => ‘Test radiobutton’,
        ‘description’ => ‘Radiobutton description’,
        ‘type’ => ‘radiobuttons’,
        ‘type_radiobuttons_options’ => array(
        array(“value” => “Yes”),
        array(“value” => “No”)
        )
        ),

        With those one, it appears but there is a bug.

  1. gagarine

    In fact this example doesn’t fully works. Mainly simple_fields_register_post_connector do not make the group a default group for the content type. Their are also absolutely no documentation for simple_fields_register_post_connector….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>