Show The Fields
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 = '')
Leave a comment