Description
Returns An array of the specified field (By given metaKey) with all duplicate values.
Parameters
1 2 3 4 5 |
<?php get_duplicate_field($metaKey,$groupIndex=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)
- $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 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?php $field1 = get_duplicate_field(book_author,1,1); // By using All parameter $field2 = get_duplicate_field(book_author,1); // using metakey groupindex $field3 = get_duplicate_field(book_author); // using metakey if($field3){ /* Displaying array value */ echo '<pre>'; print_r( $field3 ); // For displaying All array value echo '</pre>'; /* For Field output */ foreach($field3 as $field){ echo $field ."<br />"; } } else{ // do something } ?> |
Out Put
1 2 3 4 5 |
Array ( [1] => 555 [2] => 66666666666 ) |
Leave a Reply
You must be logged in to post a comment.