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.

Be Sociable, Share!

99 responses to “Types of Custom Fields.”

  1. sébastien says:

    i try this code

    $team = get_group(‘equipe’);
    foreach($team as $member){
    [1][‘photo’][1][“o”]; //[indice del grupo][nombre del campo][indice del campo][“o”]
    echo $image;
    }

    it doesn’t work…

  2. sébastien says:

    i used this code

    $team = get_group(‘equipe’);
    foreach($team as $member){
    [9][‘photo’][26][“o”]; //[indice del grupo][nombre del campo][indice del campo][“o”]
    echo $image;
    }

    but i have an error message

  3. sébastien says:

    i don’t understand what you use [indice del grupo][nombre del campo][indice del campo][“o”] in the function get_group()
    could you help me please ?
    thanks

  4. hunk says:

    dump the array,

    $team = get_group(‘equipe’);
    pr($team); //see the contain of array

  5. sébastien says:

    i have do that but i don’t understand. What is the syntax ??

    the content of pr($team) is

    Array
    (
    [1] => Array
    (
    [photo] => Array
    (
    [1] => Array
    (
    [o] => http://toto.com/wp-content/files_mf/1285786830Tree.jpg
    )

    )

    [nom] => Array
    (
    [1] => sergio
    )

    )

    [2] => Array
    (
    [photo] => Array
    (
    [1] => Array
    (
    [o] => http://toto.com/wp-content/files_mf/1285787116TocoToucan.jpg
    )

    )

    [nom] => Array
    (
    [1] => tobi
    )

    )

    )

    i use this code

    echo [1][‘photo’][1][“o”];

    that doesn’t work; what is the line to display images ?

  6. Gnuget says:

    this is not the best place for get support, please open a thread in the google group http://groups.google.com/group/magic-fields

  7. sébastien says:

    i use this code too :
    $team = get_group(‘equipe’);
    pr($team); //see the contain of array
    $image=[1][‘photo’][1][“o”];
    echo get($image);

    that doesn’t work

  8. sébastien says:

    yes gnuget, sorry

    i have post the question here : http://groups.google.com/group/magic-fields/browse_thread/thread/3b29863639b69352

    thanks to help me

  9. sébastien says:

    ok. if you have the same problem, the response was :

    $team = get_group(‘equipe’);
    foreach($team as $member){
    echo $member[‘nom’][1];
    echo $member[‘photo’][1][‘t’];//thumbnail
    echo $member[‘photo’][1][‘o’];//image
    }

  10. […] to set-up, and still very appealing for an inexperienced user.  Magic Fields allows you to set up Custom Post Types simply by having you fill out a form with the details.  It will automatically add a tab on the […]

  11. […] Fields: magicfields.org/types-of-custom-fields/ wiki.magicfields.org/doku.php?id=getting_started […]

  12. […] be retrieved with this code:get(‘field_name’);If you need more informations you can see the specific code for each type of field.The CategoriesThere are some core functions to work with the categories.The […]

  13. Chuot Lac says:

    We can use shortcode in Multiline field, but shortcode always show in the top of content.
    Ex.
    The first line. [my_shortcode]. End line
    And the result is always [my_shortcode] The first line. End line.

    Do you have any idea to fix it?

  14. prabhu says:

    Hi all ,
    this is prabhu
    iam not getting choose file for uploading images
    can anyone help regarding this issue

  15. Nice documentation! thank you!

  16. Marion says:

    Hello !

    I want to display date in this format : dd/mm/yyyy (in french dd/mm/aaaa).

    Is it possible easily ? How can I do ?

    Thank you

  17. […] But if we are using Magic Fields the custom fields data will be retrieved with this code (more informations here): […]

  18. […] методы я взял здесь (eng). Статья была опубликована в сентябре 2009 года, а […]

  19. Charles says:

    How to use get_group(‘audio’); function on multiple template?
    I need to display different template as well as mobile site template.