A Basic Example

I have created a post type “car” with the following magic fields:

Label Name Type Can be duplicated
Brand brand Textbox No
Body Style body_style Checkbox List No
Manual Transmission manual_transmission Checkbox No
Engine engine Radiobutton List No
Description description Multiline No
Image image Image No
Related related Related Type Yes

I have also created an item in post type “Car” as follows:

Name Value
brand “Plymouth”
body_style “coupe”,”2-door”
manual_transmission Yes
engine “440 triple 2 barrel”
description “1. low cost\n2. high performance\n3. no frills>”
image http://localhost/wp/wp-content/files_mf/cache/th_be8f84320c4b0287e2f36c70f177162a_1354153686Roadrunner.jpg”
related “1969 Dodge Charger”, “1970 ‘Cuda”

Let us access these fields using Magic Fields’ PHP functions as follows:

Textbox

get("brand") returns: "Plymouth"
get_data("brand",1,1,$post->ID) returns: Array
(
    [meta_id] => 2815
    [meta_value] => Plymouth
    [type] => textbox
    [options] => Array
        (
            [evalueate] => 1
            [size] => 25
        )

    [description] => 
    [label] => Brand
)
get(“brand”)     evaluates to:     “Plymouth”

Checkbox List

Since a multi-valued Dropdown behaves like a Checkbox List the below also holds for a multi-valued Dropdown.
get("body_style") returns: Array
(
    [0] => coupe
    [1] => 2 door
)

get_data("body_style",1,1,$post->ID) returns: Array
(
    [meta_id] => 2816
    [meta_value] => Array
        (
            [0] => coupe
            [1] => 2 door
        )

    [type] => checkbox_list
    [options] => Array
        (
            [options] => coupe

convertible

2 door

4 door

notchback

fastback
            [default_value] => 
        )

    [description] => 
    [label] => Body Style
)
implode(“, “, get(“body_style”))     evaluates to:     “coupe, 2 door”

Checkbox

get("manual_transmission",1,1,NULL) returns: 1
get_data("manual_transmission",1,1,$post->ID) returns: Array
(
    [meta_id] => 2817
    [meta_value] => 1
    [type] => checkbox
    [options] => Array
        (
        )

    [description] => 
    [label] => Manual Transmission
)
(get(“manual_transmission”)) ? “Yes” : “No”     evaluates to:     “Yes”

Radiobutton List

get("engine") returns: "440 triple 2 barrel"
get_data("engine",1,1,$post->ID) returns: Array
(
    [meta_id] => 2818
    [meta_value] => 440 triple 2 barrel
    [type] => radiobutton_list
    [options] => Array
        (
            [options] => 383 4 barrel

440 4 barrel

440 triple 2 barrel

426 dual 4 barrel
            [default_value] => 
        )

    [description] => 
    [label] => Engine
)
get(“engine”)     evaluates to:     “440 triple 2 barrel”

Multiline

get(“description”) returns: “<p>1. low cost</p><p>2. high performance</p><p>3. no frills</p>”
get_data("description",1,1,$post->ID) returns: Array
(
    [meta_id] => 2819
    [meta_value] => <p>1. low cost</p><p>2. high performance</p><p>3. no frills</p>
    [type] => multiline
    [options] => Array
        (
            [height] => 3
            [width] => 23
            [hide_visual] => 0
        )

    [description] => 
    [label] => Description
)
get(“description”)     evaluates to:     “<p>1. low cost</p><p>2. high performance</p><p>3. no frills</p>”

Image

get("image") returns: "http://localhost/wp/wp-content/files_mf/1354153686Roadrunner.jpg"
get_data("image",1,1,$post->ID) returns: Array
(
    [meta_id] => 2820
    [meta_value] => 1354153686Roadrunner.jpg
    [type] => image
    [options] => Array
        (
            [css_class] => magic_fields
            [max_height] => 
            [max_width] => 
            [custom] => 
        )

    [description] => 
    [label] => Image
)
get(“image”)     evaluates to:     http://localhost/wp/wp-content/files_mf/1354153686Roadrunner.jpg&#8221;
get_image("image") returns: "<img src='http://localhost/wp/wp-content/files_mf/1354153686Roadrunner.jpg' class="magic_fields" />"

Related Type

get_count_field('related') returns: 2 (this is a multi-valued field)
get_field("related") returns: Array
(
    [1] => 192
    [2] => 186
)

get('related',1,1) returns: 192 (which is a post id)
get_data('related',1,1,185) returns: Array
(
    [meta_id] => 2821
    [meta_value] => 192
    [type] => related_type
    [options] => Array
        (
            [post_type] => car
            [field_order] => id
            [order] => asc
            [notype] => 
        )

    [description] => 
    [label] => Related
)
get_the_title(get(‘related’, 1, 1))     evaluates to:     “1969 Dodge Charger”
get('related',1,2) returns: 186 (which is a post id)
get_data('related',1,2,185) returns: Array
(
    [meta_id] => 2822
    [meta_value] => 186
    [type] => related_type
    [options] => Array
        (
            [post_type] => car
            [field_order] => id
            [order] => asc
            [notype] => 
        )

    [description] => 
    [label] => Related
)
get_the_title(get(‘related’, 1, 2))     evaluates to:     “1970 ‘Cuda”

 

Addenda

Magic Fields of Post Type “Car”

Magic Fields of Custom Post Type "Car"

Magic Fields of Custom Post Type “Car”

An Item of Post Type “Car”

An Item of Post Type "Car"

An Item of Post Type “Car”