Calce

Remodelling in process

Show The Fields

18

There are two ways to show your fields' data, by using shortcodes and by using the provided function field_get_meta()

Shortcodes

Shortcodes are used to show your custom fields' values in a post or page. To use a shortcode, first make sure you've setup your boxes and fields for the post/page you wish to take data from. Please prefer to Fields, Where To Start on how to setup your fields. Here are the provided shortcodes from Fields:

[Fields]

Display values from a field of a post or page

  • key: required. The key to the field being displayed.
  • single: default is 'yes'. Possible values are 'yes' and 'no'. Use 'no' if you wish to display values of a multiple-value-capable field such as Text fields and Check boxes
  • separator: the separator when display in between a field's values
  • first_separator: first separator.
  • last_separator: last separator.
  • before: text to display before a value list
  • after: text after value list
  • before_item: text to display before all items in a value list
  • after_item: text to display after all items in a value list
  • slug: the slug of a post, page or any custom post type. If assigned a value, the shortcode can show field values from other posts.
  • post_type: to be used with slug to specify the post type the shortcode references to. Default value is the same type of the post where the shortcode resides.
  • post_status: only show cross-post value from posts with this status. Possible values are: 'publish', 'pending', 'draft', 'future', 'private' and 'trash'.

Example:
[field key='data1']
[field key='data1' slug='hidden-post' post_type='page' post_status='private']

[Field_count]

Used to count the number of values in a field that has more than one value

  • key: required. The key to the field being displayed.

Get data the geeky way

Just call: field_get_meta($key, $single = true, $id = '')

Comments (18)

rss
  • AnyDog

    Hi, I just discovered your plugin ( I was using “More fields” adn “Magic Fields” before) and I found it very easy to administer.
    Especially I like grouping of boxes and fields.

    However, I have a big question:
    Can I do a query filtered by meta data that was made by your plugin ?You know, like :
    query_posts(‘meta_key=mykey&meta_value=meta_value&showposts=5&cat=1′);

  • Hi AnyDog,

    Yeah you can, just put an underscore ‘_’ in front of the key name, e.g.


    query_posts(‘meta_key=_mykey&meta_value=meta_value&showposts=5&cat=1′);

  • It won’t works for fields with multiple values though

  • AnyDog

    Yeah, I digged into database and realized there is a _ before key.
    Oh, and you anticipated my next question, and that is very important question for me …
    OMG, such a shame it don’t work with multiple values … That’ very important to me, because I have to filter posts with multiple values …
    Any chance it will work in (possibly, near) future ?

  • AnyDog

    And, how come that custom fields created with your plugin don’t show up in WordPress standard custom fields box ?
    With other custom fields plugin they show up …

  • If you put an underscore in front of the key, it won’t show up

  • AnyDog, try the unordered textfields in 0.4.3, you should be able to query

  • AnyDog

    Ok, Khanh … Thank you for your replies.
    I managed to filter posts using custom query, not WP’s query_posts function (or WP_query or get_posts… ;) )

    I have another question. I did box with two groups – and in the post admin i got two group tabs in the left side od the box. Is there a (easy) way to make this tabs on the top, instead of on the left side ?
    These tabs are pushing fields outside parent div, so I must make my browser fullscreen to see full fields …
    Thanks.

  • Oh it’s WordPress’s default layout to put the tabs on left. If you really need them on the top, you need to put some more css in :-)

    Have you tried the one-column layout for the groups?

  • AnyDog

    I will try one-column layout if I fail to change css (or if it’s gonna be too much work … I’m lazy ;) ).
    It’s really nice to have tabbed groups. That way you have less to scroll and you can organize better fields. I wouldn’t like to lose tabs …

    Ok, Khanh, thank you for great plugin and for all your extra help !
    Bye,bye

  • Thanks :-)

  • Jon

    Hi there, Whilst I can call the field information through the post using the shortcodes, im struggling to understand how to call the various groups and fields within my template – I have tried the various snippets of code, but unfortunately cant seem to get anything to display.

    Im not great with PHP and so due to the minimal instructions on how to call this im at a bit of a loss.

    Can you help me out please and give a little more description as to how I might call the information from within my post template.

  • Blake

    Could you please explain in further detail how to display fields in post the geeky way. Thank you for the great plugin!

  • I found a big bug with text fields with multiple unordered values. Basically in the admin, only the first letter of each field is shown, like in this screenshot: http://d.pr/flxR

    I solved it by replacing $value['value'] in fs-textfield.php at line 99, with $value

    I don’t know yet if anything else broke, but for the moment it will do.

  • Hello!
    I’m very happy to use this plugin which is very great!
    For my project, I had to display my custom fields in custom types post with PHP code ; and i’m not a pure developper ;-)

    So for an event i have fields date of begin and date of end. So i would like display just date of begin if date of end is empty, and the two dates if they are informed.

  • Sorry : i have finded the solution ;-)

  • eh non, it’s not really working…

  • Here my code: i know is wrong, so someone can help me?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge