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.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • BarraPunto
  • LinkedIn
  • Meneame
  • Reddit
  • Slashdot
  • Tumblr

97 Responses to “Types of Custom Fields.”

  1. wardy says:

    Any chance of a google map field type?

  2. Okay. Here’s the ultimate-they-gotta-add-this idea. After all, you CAN do the Google map using a textline and some code of your own. But this idea is WAY better.

    A Widget Group type. Totally new idea. If you specify a group to be a widget then that widget becomes available for your sidebar use and you can use all the various fields to embed interesting content with the page that will show up With That Page Only in the widget (if you’ve put that widget in a sidebar).

    You could use this to do Author sidebar widgets, Table of Contents for the first page, Sidebar google maps that relate to the page content, on and on.

    Please do this guys!

  3. francesco says:

    Hi,
    sorry my ignorance, but what code for radio button?
    thanks

  4. Andrew says:

    is there anyway to echo the value from a listbox option, i don’t want to echo the string, what’s the point of the value anyway? I set the values for each list option as (file name).swf and would like the user to be able to choose one from the list but i don’t want it to say the filename as an option.

  5. [...] y es una de las extensiones más potentes en su clase, con la capacidad de declarar hasta doce tipos distintos de campos personalizados, que incluyen el editor WYSIWYG de WordPress. Aunque ha sido recientemente actualizado y es [...]

  6. [...] plugins om ook op een simpele manier Custom Fields toe te voegen aan je Custom Post Type. Magic Fields (WP.org repository) heeft de meeste Field-types. Denk bijvoorbeeld aan Sliders en Audio. De [...]

  7. nzahn says:

    Great upgrade (1.4.5), finally we have Media upload, but how can we call it? Is it the same then the other get_image call? or does it have something special?

  8. Courtney says:

    Is there a way to a) hide the download link on the audio and b) encode the mp3 location, so that people can’t get the mp3 path?

    Thanks.

  9. hunk says:

    Hi nzahn you can use get_image and gen_image

    Hi cournet a)yes, add ?showDownload=false in the funtion get_audio (check this examples http://www.seanhailey.com/mp3/singlemp3player.html) is the same player

  10. Hen says:

    I discovered there is a small bug for your magic field, when i activated it, and go to “Media” > “Library”, edit any uploaded image or attachment. The few text fields and labels are disappeared:
    ——–
    Title*

    Alternate Text

    Caption

    ——–
    Please check

  11. James says:

    I don’t understand how you set the width or height when using the new phpthumb system – I can generate the image with but that gives me the full size image, where do I set the width and height?

  12. Gnuget says:

    http://wiki.magicfields.org/doku.php?id=front-end_functions#gen_image there you can found a few examples about how set the width and height.

  13. chad says:

    I am using magic fields for a custom write panel with an image upload. The image also gets pulled into the side of the site which is on every page of the site, the image shows up on the home page when any other page is selected it disappears – the image is the tshirt on the right.

    home: http://bicyclenerd.com/fall
    sub-page( no image ): http://www.bicyclenerd.com/fall/archives/4

    This is how I call it:
    <img src="http://bicyclenerd.com/fall/wp-content/themes/bnfall2/timthumb.php?src=&h=250&w=250&q=50&zc=1);”>

    Any help would be great!

  14. James says:

    Chad, have you fixed it? Im using safari on my iphone and its displaying on both pages.

  15. sébastien says:

    i use duplicate group, and I have an image in each group. What can i display each photo ?
    i used this code :
    $team = get_group(‘team’);
    foreach($team as $member){
    echo $member['namemember'][1];
    echo “”;
    echo $member['photomember'][1];
    echo “”;
    }

    for the name it’s ok, but the photo is always the same for each member…
    could you help me ?

    }

  16. sébastien says:

    Hunk, i have red this post. I use get_group but what can i display each image ?

    i try with this code :
    $team = get_group(‘team’);
    foreach($team as $member){
    echo $member['name'][1];
    echo $member['image'][1];
    }

    one more time it’s ok with the name but it doesn’t work with image. What is the code to display each image in a duplicate group ? please.

Leave a Reply

Stop SOPA