Retrieving data
Because Cuztom uses the builtin meta functions, retrieving data is very easy.
// Post
$data = get_post_meta(get_the_ID(), '_data_text_field', true);
// User
$data = get_user_meta(80, '_data_text_field', true);
// Term
$data = get_post_meta(80, '_data_text_field', true);
Image fields
When using an image field, Cuztom only stores the attachment ID, so retrieving the data is a little bit different.
$data = get_post_meta(get_the_ID(), '_data_text_field', true);
$image = wp_get_attachment_image($data);
Read more about wp_get_attachment_image on the Wordpress Codex.
Date and time
Date, time and datetime are saved in a UNIX timestamp. SO to get u human readable date or time, you can do the following:
$data = get_post_meta(get_the_ID(), '_data_datetime', true);
// Date
$date = date(get_option('date_format'), $data);
// Time
$time = date(get_option('time_format'), $data);
// Datetime
$datetime = date(get_option('date_format').' '.get_option('time_format'), $data)
Bundles
The bundles are stored in an array using the bundle's ID.
$data = get_post_meta(get_the_ID(), '_bundle_name', true);
This will print out an array in the following format:
Array
(
[0] => Array
(
[_field_id] => Field Value
[_another_field_id] => Another Field Value
)
[1] => Array
(
[_field_id] => Field Value
[_another_field_id] => Another Field Value
)
...
[n] => Array
(
[_field_id] => Field Value
[_another_field_id] => Another Field Value
)
)
Updated over 8 years ago