get_field()
Description
Returns the value of the specified field (By given metaKey).
This function will return the Field single value . It has four parameter .
Parameters
|
1 2 3 4 5 |
<?php
get_field($metaKey,$groupIndex=1,$fieldIndex=1,$post_id=null);
?> |
- $metaKey: The Meta key of the field . eg “book_author” (required)
- $groupIndex:Specific group index if you have duplicate group. Defaults to 1 (not required)
- $fieldIndex:Specific field index if you have duplicate field. Defaults to 1 (not required)
- $post_id: Specific post ID where your value was entered. Defaults to current post ID (not required)
Usage
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php
$field1 = get_field(book_author,1,1,2); // By using four parameter
$field2 = get_field(book_author,1,1); // using metakey groupindex, fieldindex
$field3 = get_field(book_author); // using metakey
if($field3){
echo $field3;
} else{
// do something
}
?> |

