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. Markgt says:

    Hi there

    ive got a question about the Checkbox list – i got it to echo all the options in the page template, but HOW do i echo ONLY the ones that have been ticked??

    any help would be appreciated. thanks!

  2. Dan says:

    Love the plugin so far, great work you guys. I used PODs on a previous site and I like that as well, but I like the simplicity of this plugin. I do have a small question though. Is it possible to create field a that has 2 values or input fields?

    For example: Let’s say I want to show a list of Services. For each service there is some text and icon. I am imagining hitting the “duplicate” button in the panel and 2 fields are generated; One for the icon url and the other for the text. Is this possible?

  3. Dan says:

    Never mind my comment above. Got it figured out, I totally overlooked the “Groups” option, which is very powerful. :-) Thanks for making this!

  4. KJ says:

    First off I’d like to say great job at making a better version of flutter, its nice to see the plugin will live one.

    One thing that would be nice is to put all the documentation at the top of this page. I had to skim through all the comments to find the function to obtain all the fields (with values) of a group.

    Cheers

  5. Gnuget says:

    Hi,

    You are right, we are thinking in give a new skin to the magic fields page… we will take in account your suggestion. for to in the next version of the page all will more easy to access.

  6. Markgt says:

    Hi Gnuget and Hunk

    been looking around and this is still the most versatile custom write panel plugin around – keep up the work!

    ONE question: is there any way to either:

    1) use the “Related Type” with a list of checkboxes rather – ie list the pages created by another write panel?

    2) use the “checkbox list” but instead of inputting the options, rather reference the pages of a particular parent page?

    I think this would be a powerful feature – eg you could tick, from a list, all the PRODUCTS that a certain SUPPLIER stocks (where PRODUCT and SUPPLIER are custom write panels.

    is there any way to do this / possibility of it being implemented?

    thanks for the great plugin!

  7. Dan says:

    Quick question, is it possible to integrate Pagination with content populated by Magic Fields?

    For example; I have a simple “News” area that is setup via Magic Fields and set to Post for Placement. Basically the idea is to have a page that displays 10 “News” Posts and then has pagination to navigate through the posts.

    I realize this can be done easily by just making making a “News” category under the WP posts; but I am trying to keep away from doing this as I want the blog section of the site to be controlled by that.

    Thanks!

  8. tom says:

    @dan use a category but exclude it from your blog loop

  9. Dan says:

    @tom – I’m not sure I am following you a 100%. I tried doing the above (my previous comment) with just the traditional post and assigning it to a category, to which I ran into a bit of a snag. Here’s an idea of what I’ve got.

    I have 5 main pages, most have sub pages. One of these main pages is “About” with a sub section of “News” … on this “News” page I’d like to display Posts from a certain category, which I did. But what I don’t like is how when you click on “Continue Reading” to read the full “News” post it uses the “single.php” template.. I could just modify the single.php template to look just like my “News” subpage, but I really don’t want to do that. What I’ve been searching for online is something related to Assigning Posts to Pages. But from what I understand it’s not possible? I found a couple plugins but they didn’t do what I wanted.

    I’d really like this to be powered through Magic Fields if its possible. The biggest disconnect I am having is when you are on the “News” page (subpage of About) you see a list of “News” posts and when you click on an individual post you are still in the same template as “News” and the URL would be something like “www.mywebsite.com/about/news/name-of-post”

    Sorry for the novel. haha. Any thoughts on how the best approach for this? I push for Magic Fields simply because a full on blog will be added to the site later on and I REALLY want to keep all “blog” related content separate.

    Thanks!

  10. tom says:

    http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/

    look here for ‘Unique Single template’, I’d certainly go this way,unless you had a particular reason for wanting to use a page.

    I’d rework the link structure and use a custom category template for your category (eg category-news.php) then set your category structure to something nondescript but relevant, for example on my site I have

    http://www.mysite.com/website-design/portfolio/site-i-designed

    where /website-design/ is used instead of /category/ (change in permalink settings) /portfolio/ is the category (controlled by magic fields) and /site-i-designed/ is the post using a custom single.php also configured to %%title%% in permalinks. Then for your blog edit index.php to exclude news category and use the default single.php

    I’d stop search engines following by category after this but that’s really a matter of the site you have and I’m certainly no SEO expert.

    cheers :)

  11. tom says:

    should say …category permalink structure to something nondescript……..

  12. Dan says:

    @tom – thanks a bunch. I think that might just be what I am looking for. I will give it a go.

    @terry – thanks for the plugin link.

  13. zestylemon says:

    I’d really appreciate it if someone could tell me what code snippet I use to display the contents of a Dropdown List.

    In the article one of the sections is ‘Dropdown List’ but the content immediately below it is for ‘Checkbox List’.

  14. How can I use textline to just get an URL? It adds DIV formatting around the returned result.

    Kermit Woodall
    Managing Editor
    GadgetNutz.com

  15. Forget it. Figured out you need to assign it to a variable instead of just echoing it.

    Kermit Woodall
    Managing Editor
    GadgetNutz.com

  16. No wait…that didn’t work…damn.

    Kermit Woodall
    Managing Editor
    GadgetNutz.com

  17. …and the ultimate solution was to turn OFF the Edit in Place options. Just in case anyone wants to know.

  18. [...] Link: Types of Custom Fields. | Magic Fields [...]

  19. [...] Read more here: Types of Custom Fields. | Magic Fields [...]

Leave a Reply

Stop SOPA