Get field values
<?php CFS()->get( $field_name, $post_id, $options ); ?>
Parameter | Required | Type | Notes |
---|---|---|---|
$field_name | N | mixed | Enter a field name, or FALSE to get all fields |
$post_id | N | mixed | Enter a post ID, or FALSE to use the current post ID |
$options | N | array | $options['format'] can be ‘api’, ‘input’, or ‘raw’ |
Examples
Output a field value
<?php
echo CFS()->get( 'first_name' );
Store all field values for the current post
<?php
$fields = CFS()->get();
Output a field from a specific post ID
<?php
echo CFS()->get( 'first_name', 678 );
Retrieve the raw, unformatted values for post with ID = 42
<?php
$field_data = CFS()->get( false, 42, array( 'format' => 'raw' ) );
Get values from within a loop
<?php
$loop = CFS()->get( 'gallery' );
foreach ( $loop as $row ) {
echo $row['gallery_title'];
echo $row['gallery_image'];
}