Creating options in the WordPress backend just got easier than ever! With
pwp_field() you can create options for your theme or plugin quickly without worrying about retrieving the field’s value once something is saved or registering the right hooks for things to work properly. Premise WP will take care of all this for us. Lets take a look at how you can use this powerful function.
Important: In Premise WP 2.0.0
premise_field was deprecated and replaced with
array|string Optional. Set of arguments to build a field. Defaults to an empty string.
boolean Optional. Whether to echo or return the html for the field. Defaults to true.
Arguments are used to build our field’s html. If the argument does not serve a specific purpose for our field such
wrapper_class – which adds a class to our field’s wrapper, then it is added to our field as a html attribute. Below is a list of attributes that
pwp_field accepts as the first parameter.
string – The element tag to use when building the field. i.e. input or button.
string – Type attribute to use for the input field. Can use textarea or select as well.
string – The name attribute.
string – The id attribute.
string – The value. Leave empty if you want Premise WP to get value when something is saved.
string – For checkbox and radio buttons, set a value attribute. Default is ‘1’.
array – Option to use for a select field. Format
text => value
string – The context in which the field is being used/saved. Can be post or user. When post or user is used Premise WP looks up the value saved for this field under a post or a user respectively. Otherwise it looks under the options table.
string – Set a default to use as the value when nothing has been saved.
string – Enter the text to use for the field’s label.
string – Enter text or html before the field’s wrapper.
string – Enter text or html after the field’s wrapper.
string – Add a class to the field’s wrapper.
string – Enter text or html before the field.
string – Enter text or html after the field.