Tutorial by Examples

<?php echo get_field('my_field_name'); ?> This will echo the value of the field "my_field_name" from the current post.
<?php echo get_field('my_field_name', 123); ?> This will echo the value of "my_field_name" from the post with 123 as its ID.
<?php echo get_field('my_field_name', 'option'); ?> This will echo the value of "my_field_name" from the options page created via ACF.
<?php if( get_field('my_field_name') ){ ?> <?php echo get_field('my_field_name'); ?> <?php }; ?> This will only show the field if content exists depending on content type (i.e., an image is uploaded to the field, text is entered, it is selected, etc.).
It's a good idea to sanitize get_field() output, especially when using Advanced Custom Fields fields front end (with acf_form()). Otherwise your site is likely vulnerable to cross-site scripting attacks (XSS). The following function lets you use echo get_field_escaped('my_custom_field', $post_id, ...
Here's an example on how to use ACF to output differently based on options (color selections in this case). While you can use <?php echo get_field('color_options'); ?> to output the value directly, you can also change the markup depending on the selection. <?php $option = get_field('color_...

Page 1 of 1