Skip to content

Instantly share code, notes, and snippets.

View antiden's full-sized avatar
🎯
Focusing

antiden antiden

🎯
Focusing
View GitHub Profile
@antiden
antiden / acfrepeater.txt
Last active January 9, 2017 07:04
WP ACF Repeater
<?php if( have_rows('repeater_field_name') ): ?>
<?php while ( have_rows('repeater_field_name') ) : the_row(); ?>
<?php the_sub_field('sub_field_name'); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
/*Count fields*/
<?php
$i = 1;
@antiden
antiden / acfflexible.txt
Created January 9, 2017 07:05
WP ACF Flexible Content
<?php if( have_rows('flexible_content_field_name') ): ?>
<?php while ( have_rows('flexible_content_field_name') ) : the_row(); ?>
<?php if( get_row_layout() == 'paragraph' ): ?>
<?php the_sub_field('text'); ?>
<?php elseif( get_row_layout() == 'download' ): ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
@antiden
antiden / acfgallery.txt
Created January 9, 2017 07:05
WP ACF Gallery
<?php $images = get_field('gallery'); ?>
<?php if( $images ): ?>
<ul>
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<p><?php echo $image['caption']; ?></p>
</li>
@antiden
antiden / acfrelationship.txt
Created January 9, 2017 07:05
WP ACF Relationship
<?php $posts = get_field('relationship_field_name'); ?>
<?php if( $posts ): ?>
<ul>
<?php foreach( $posts as $post): ?>
<?php setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span>Custom field from $post: <?php the_field('author'); ?></span>
</li>
<?php endforeach; ?>
@antiden
antiden / acftruefalse.txt
Created January 9, 2017 07:06
WP ACF TrueFalse
<?php if( get_field('field_name') ) { ?>
<?php } else { ?>
<?php } ?>
@antiden
antiden / acffield.txt
Created January 9, 2017 07:06
WP ACF Field
<?php if(get_field('logo')) { ?>
<?php echo get_field('logo', $post_id) ?>
<?php } ?>
<?php if(get_field('logo')) { ?>
<?php the_field('logo') ?>
<?php } ?>
@antiden
antiden / acfimageobject.txt
Created January 9, 2017 07:07
WP ACF Image Object
<?php $image = get_field('thumbnail'); ?>
<?php if( !empty($image) ) { ?>
<div class="article_thumb">
<?php
$url = $image['url'];
$title = $image['title'];
$size = 'news';
$thumb = $image['sizes'][ $size ];
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $thumb; ?>" alt="<?php the_title(); ?>"></a>
@antiden
antiden / acfgooglemap.txt
Created January 9, 2017 07:07
WP ACF Google Map
<?php $location = get_field('location'); ?>
<?php if( !empty($location) ): ?>
<div class="acf-map">
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
</div>
<?php endif; ?>
@antiden
antiden / acfbfithumb.txt
Created January 9, 2017 07:08
WP BFI thumb
<?php
$params = array( 'width' => 1200, 'height' => 500 );
$bfi_image = bfi_thumb(get_field('thumb'), $params);
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $bfi_image; ?>" alt="<?php the_title; ?>"></a>
@antiden
antiden / wppostloop.txt
Created January 9, 2017 07:08
WP Post Loop
<?php if ( have_posts() ) : ?>
<?php $main_news_first = new WP_Query('category_name=news&posts_per_page=1'); ?>
<?php while ($main_news_first->have_posts()) : $main_news_first->the_post(); ?>
<div class="main_news_first">
<div class="main_news_first__box">
<div class="main_news_first__box--image">
<?php
$params = array( 'width' => 1200, 'height' => 500 );
$bfi_image = bfi_thumb(get_field('thumb'), $params);
?>