Skip to content

Instantly share code, notes, and snippets.

@iainmcampbell
Last active August 29, 2015 14:13
Show Gist options
  • Save iainmcampbell/c71b09e7237b5898aaa0 to your computer and use it in GitHub Desktop.
Save iainmcampbell/c71b09e7237b5898aaa0 to your computer and use it in GitHub Desktop.
Advanced Custom Fields
<?php
$imageID = get_field('image_field_name'); // set this field to return Image ID
$size = 'full'; // thumbnail, medium, large, full
$img = wp_get_attachment_image_src( $imageID, $size );
if( !empty($image) ):
$url = $img[0];
$width = $img[1];
$style = 'max-width:'.$width.'px';
?><img src="<?php echo $url ?>" style="<?php echo $style ?>"><?php
endif;
?>
<?php
acf_add_options_page(array(
'page_title' => 'Theme Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-settings',
'capability' => 'edit_posts',
'redirect' => false
));
?>
<?php
if( have_rows('repeater_field_name') ):
while( have_rows('repeater_field_name') ):
echo get_sub_field('sub_field_name');
endwhile;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment