Text field

The text field is a field for plain text. Use the text field if you need to store small and simple bits of text, like names of people and captions for images.

Example usage

The text field as it looks on the edit post screen.


// Slug of field is "textExample"
$value = simple_fields_value('textExample');
echo $value;

Output of above:


This is some text written

Add a field group with a text field using PHP code


simple_fields_register_field_group('feature_options',
	array (
		'name' => 'Feature Options',
		'description' => "",
		'repeatable' => 0,
		'fields' => array(
			array(
				'slug' => "link",
				'name' => 'Link',
				'description' => 'Requires http://',
				'type' => 'text',
				'options' => array(
					'subtype' => 'url',
					'placeholder' => 'http://example.com/'
				)
			)
		)
	)
);

4 thoughts on “Text field

  1. karuna

    Just started learning php about 2 days ago and I’m stuck!

    This may be your simplest question ever but here we go:

    My Meta key: _simple_fields_fieldGroupID_1_fieldID_2_numInSet_0

    Field group name: Options

    Field name: link

    What I’ve inserted in my php page (it’s the correct page, my none php text shows up)

    On the post I’ve added to the Custom field “Options” however I cannot get the text!

    In how many ways is what I’ve done incorrect?

    Thanks!

Leave a Reply