get the field acf code example

Example 1: get custom field

/* put this code in home.php file create in child theme  */

<?php 
 /*Template Name: Home Template*/
 
echo get_post_meta($post->ID, 'Name', true); 
  
?>
 /* Or use this code  */
 <?php 
	$value =get_field('Name');
	echo $value;
?>

Example 2: get field of acf texonomy

<?php 

// load thumbnail for this taxonomy term
$thumbnail = get_field('thumbnail', $term->taxonomy . '_' . $term->term_id);

?>

Example 3: get field acf

$content = get_field('content', $post_id);

Example 4: acf get field

$value = get_field( "text_field" );

if( $value ) {
    echo $value;
} else {
    echo 'empty';
}

Example 5: get field object acf

get_field_object('content', post_id);

Tags:

Php Example