Main menu

Custom Post Fields

This post contains an example of the Custom Post Fields.


Post note:
Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nulla vitae elit libero, a pharetra augue. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
Post last updated by:
Post will be removed on:
Next Monday

Image Post

This is an example of the Image Post Format:

Web Responsive Design

Web Responsive Design is fully supported by the GavernWP Framework

Aside Post

This is an example of the Aside Post Format, which can be used to show less important posts.

Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Sed posuere consectetur est at lobortis. Nullam id dolor id nibh ultricies vehicula ut id elit. Curabitur blandit tempus porttitor.

Quote Post

This is an example of the Quote Post Format:

Thank you for the great customer service! I appreciated that you had someone to help me, even though it was 2:45 a.m. where I am.

Amanda Turner

Video Post

This is an example of the Video Post Format:

Tip: for Vimeo videos please remember about using the HTTP (not HTTPS) protocol and the “www.” prefix.

Option files

Modification of administration panel content  in GavernWP is very easy – it is based on JSON files which include a list of options. Thanks to it, creating new options available in an administration panel is very easy.

Options files are in gavern/options catalog in a folder connected with a currently used language. In the catalog, you will find two main files groups:

  • tabs.json file – it includes a list of sections visible on the right side of an administration panel:  each section is described with a table in the form
    ["Basic", "options.basic", "enabled"]
    the first element of a table is a section name displayed in a panel, the second element is a file name without “.json” extension which stores a list of options available in a section given and the third value refers to whether a section given is visible in a panel. In this case, there will be a Basic tab displayed in a panel based on content of options.basic.json file.
  • options.*.json files – they include a list of options available in a section given – their names are strictly connected with the content of tabs.json file.

Each options.*.json file includes three main fields in an object stored:

  • groupname – it is a section title
  • groupdesc – it specifies a section description displayed directly under a  section title
  • fields – it includes a table of objects of fields displayed under the title and a section description

Each field defined by an object including the following fields:

  • name – it specifies an option name which will be connected with a particular field. There is a prefix added automatically to an option name which is a theme name (it is stored in a global variable – $tpl->name).
  • type– it specifies a field type. Standard fields are:
    • TextBlock – a field including a description text – it is not used for storing any option value
    • Text – the easiest text field allowing to insert short text values
    • Textarea – a text field used for inserting a greater number of text values
    • Select – a select field
    • Switcher – a checkbox restricted to two options: “Enabled” and “Disabled”
    • Media – a field allowing to choose images
    • WidthHeight – a field allowing to specify two values defining width and height (mostly used with a Media field)

These fields are defined in a gavern/form_elements/standard.php file and their code was derived from a GKFormInput field. It is worth remembering that files connected with options are parsed by a gavern/form.parser.php file. Additionally, you may create your own fields types in a gavern/form_elements catalog. In GavernWP, we have included the following fields types:

  • Menu – a field allowing to generate options connected with page’s menu – used in a Navigation section
  • ThemeStyle – a field allowing to choose page’s style – used at the beginning of a Basic section.

The description of creating your own fields types we will describe in the further part of this article.

  • label – it specifies a label text visible next to a field
  • tooltip – (optional) it allows to specify tooltip content which will appear after mousing over a label of a field given
  • default – default value of a field given
  • class – (optional) this field allows to specify CSS classes added to an element while generating it (if a field code supported such a functionality)
  • format – (optional) a field specifying a desired field content in the form of a regular expression. e.g. value: 
    specifies that a field given will be filled in correctly only when a user set as its value a sequence of capital or small letters from 2 to 5 symbols.
  • required – (optional) allows to specify whether filling in a particular field was required
  • visibility – (optional) specifies when a particular field is visible. Visibility rules are separated with commas and are created in FIELD_NAME=VALUE format – in the case of a few visibility rules, they are linked with AND operator. The value of  FIELD_NAME is a name without a prefix with a theme name. e.g.
    will cause that a field given will be visible when an option with option1 name will be set to 10 and, at the same time, an option2 option will have have value equals 20.
  • other – (optional) this field is used for storing additional values, e.g. in the case of a Select field, it is used for storing names and options values. This field is very useful when creating more advanced fields which may require additional configuration options.

After adding a new option, you have to remember about its support in the theme. Option value is loaded by using a get_option function of a schemata given:

get_option($tpl->name . '_OPTION_NAME', 'DEFAULT_VALUE');

when OPTION_NAME is an option name from a JSON file and DEFAULT_VALUE is default value of an option which will be used when a user does not specify a value of an option given. What is important, there is a “_” symbol which you cannot omit. A prefix with a theme name is added in order differentiate values of options of different themes.

Creating your own field types options

While creating a new field type, you have to start from creating a catalog compliant with a field name, e.g. CustomField in a gavern/form_elements catalog. Then, you have to create a config.json file in this catalog and fill it in according to the schemata below:

"name": "CustomField",
"description": "Example Custom Field",
"js": false,
"css": false,
"php": "customfield.php",
"class": "GKFormInputCustomField"

name, description, php i class fields have to include particular values; js and css fields are optional – they allow to specify whether a field given has to use additional CSS and JavaScript code (then, a name of files from a field catalog has to be set as a value). Also, you have to create a customfield.php file including a GKFormInputCustomField class derived after a GKFormInput class.

Also, a customfield.css file must include a safety code at the beginning:

// disable direct access to the file
defined('GAVERN_WP') or die('Access denied');

Each field class has to include at least one public method – output not loading any additional arguments. This method must return HTML code of a field given. Field properties froma JSON file are available as class fields, e.g. required is available as:


The second important public methid of each class of a form field is a getValue method which loads one argument – $default. Its use is optional and useful only when a value of a field given uses more than one field in the data base. Then, it is useful to overwrite this method – as an example we recommend a standard code of a WidthHeight field where overwritting a getValue method was used for storing values of two form fields in one main field created by a GKInputFormWidthHeight class.

The remaining class methods have to be created according to the needs of the author of a form  field given.

Social API settings

A section of options connected with Social API includes five groups of options:

  • options connected with sharing at Facebook
  • options connected with sharing on G+
  • options connected with sharing on Twitter
  • options connected with sharing on Pinterest
  • options allowing to switch on/off Social API on particular subpages.

Options connected with sharing are the equivalent of parameters available in online editors, used for creating buttons like:

The last group of options allows to specify where they will be displayed – thanks to Include/Exclude specified articles from Social API option, it is possible to switch off Social API completely or switch on/off this functionality only for chosen posts, subpages and categories.

We specify the list of posts, subpages and categories in three last options:

as a sequence of ID, slug or the names of posts given, subpages or categories separated with comas, e.g. 


Advanced settings

An advanced settings section includes settings which are connected with different aspects of GavernWP framework work:

  • Widget rules allows to switch on this mechanism. It is recommended to switch on this option in the case when you do not need to use widgets visible on a chosen subpages. Note that it will allow to optimize a little bit the speed of a website as operations of checking rules for each widget will not be made.
  • Support for Google Chrome Frame – it switches on a metatag forcing use of  Google Chrome Frame plugin on Internet Explorer browsers if it is installed.
  • Parse emoticons in the text widgets – it activates parsing emoticons to a graphic form in widgets.
  • Parse shortcodes in the text widgets – it activates parsing of Shortcodes in widgets.
  • Use Thickbox – it allows to switch on Thickbox  script for presenting images included in posts.
  • Value for the $content_width variable –  $content_width variable is used while creating thumbnails of images for posts, that’s why it has to be defined as an appropriate value – we recommend to set the value not bigger than the max. page’s width.
  • Use the override.css file – thanks to switching on this option, an override.css file will appear at the end of the list of CSS files which allows to overwrite theme’s CSS rules easily without interference in existing CSS code.
  • Enable support for Open Search – it allows to switch on support for  Open Search technology.
  • Enable support for Open Graph – it allows to switch on support for Open Graph  technology – after switching on this option, an additional metabox will appear on a page for editing posts: 

Main back-end features

GavernWP has an advanced panel for managing theme’s options in an administration panel. These options have been divided into a few main groups:

  • Basic settings
  • Layout settings
  • Fonts settings
  • Navigation settings
  • Advanced settings
  • Shortcodes settings
  • Social API settings
  • Theme branding settings
  • Back-end branding settings
  • SEO settings

Also, some additional elements generated by a framework in an administration panel in some various places appear, namely:

  • Typography button
  • Widget rules
  • Open Graph metabox
  • GavernWP SEO settings metaboxes

It is also worth getting acquainted with a theme configuration with files use in JSON format:

  • Option files
  • Theme configuration

The ability of these files edition, gives a possibility of deep interference in websites work based on GaverWP.

More Videos >