Created
October 27, 2013 22:42
-
-
Save leoken/7188801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Get a field object and display it with it's value | |
*/ | |
$field_name = "text_field"; | |
$field = get_field_object($field_name); | |
echo $field['label'] . ': ' . $field['value']; | |
/* | |
* Get a field object and display it with it's value (using the field key and the value fron another post) | |
*/ | |
$field_key = "field_5039a99716d1d"; | |
$post_id = 123; | |
$field = get_field_object($field_key, $post_id); | |
echo $field['label'] . ': ' . $field['value']; | |
/* | |
* Get a field object and create a select form element | |
*/ | |
$field_key = "field_5039a99716d1d"; | |
$field = get_field_object($field_key); | |
if( $field ) | |
{ | |
echo '<select name="' . $field['key'] . '">'; | |
foreach( $field['choices'] as $k => $v ) | |
{ | |
echo '<option value="' . $k . '">' . $v . '</option>'; | |
} | |
echo '</select>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment