Documentation: “Widget” File Structure

Widgets are made up of two files:

Output File

This is the only required file for widgets.  Everything in this file will display on the frontend.  It can be as simple as standard HTML or a MailChimp form.  Or it can be pulled from the Settings File.

The format of this file is: widget-name.php:  (i.e. example.php)

Settings File

This file holds the fields that will be filled in on the Widget page in the WordPress admin.

The format of this file is:  widget-name-form.php:  (i.e. example-form.php)

 

 

Comment block attributes

title
Name of Settings Section. Will appear in the section as <h3>
example: My Settings Section

descriptoin
The description of your widget, displayed in the WordPress admin
example: My new cool widget

 

Example code:

<?php
/*
Title: My Widget
Description: My new cool widget
*/

// Let's create a text box field
 piklist('field', array(
   'type' => 'text'
   ,'field' => 'field_name'
   ,'label' => __('Example Field')
   ,'description' => __('Field Description')
   ,'attributes' => array(
     'class' => 'text'
   )
 ));
 ?>