Types of Custom Fields.

In Magic Fields, there are 12 types of “fields”. Below is a detailed explanation of each “field” and how to use them in WordPress.

Please note that the code used to display each “MagicField” must be inside one of the WordPress loops. E.g. In the default theme, “the_content();” is displayed within the “single.php” file – please see the image below:

single

Textbox.

Textbox


Usage:

echo get(‘field_name’);

Return:  String.

Multiline.

For this field, the same filters used for “the_content();” may be applied using “shortcode“. Please see the images below:

multiline

shortcode

Usage:

echo get(‘field_name’);

Return: String.

Checkbox.

checkbox

Usage:

$value = get('field_name');

if($value){  /*Something*/ }

Return: Bool.

Checkbox List

check_box_list

Usage :

$my_list = get(‘field_name’);

foreach($my_list as $element){

echo   $element;

}

Return: Array

DropDown List

check_box_list

Usage:

$my_option = get(‘checkbox’);

echo  $my_option;

Return: String

ListBox

Add New Post ‹ Magic Fields — WordPress

Usage:

$my_list = get(‘field_name’);

foreach($my_list as $element){

echo   $element;

}

Return: Array

Images

image-1

Usage:

$my_image_url = get(‘field_name’);

/**

* With this method is returned the absolute url

* of the image

**/


get_image(‘field_name’);

/**is returned the image tag of html**/

Return: String

Date

date2

date

Usage:

$my_date = get(‘field_name’);

Return: String. (Return the date in the same format  to was selected when was created the custom field, actually exists 8 differents formats of dates)

Audio

Audio

Usage:

$mp3_url = get(‘field_name’);

/**

* With this method return

* the absolute url of the image

**/


echo get_audio(‘field_name’);

/**

*With this method return a flash player

* for the user can ear the song

**/

Color Picker

color_picker1

colorpicker2

Usage:

$color = get(‘field_name’);

Return : String  (hexadecimal number of the Color )

Slider

slider

Usage:

$value = get(‘field_name’);

Return: String.

Stop SOPA