Skip to content

Instantly share code, notes, and snippets.

@seanwash
Last active April 15, 2016 16:42
Show Gist options
  • Select an option

  • Save seanwash/25e7bd28e6812c5b183019dee0866762 to your computer and use it in GitHub Desktop.

Select an option

Save seanwash/25e7bd28e6812c5b183019dee0866762 to your computer and use it in GitHub Desktop.
Wordpress Snippets
<?php // custom query loop ?>
<?php $counter = 0; $loop = new WP_Query(array('post_type' => 'capability', 'posts_per_page' => -1)); ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<div>
<?php the_title(); ?>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php // get images from ACF gallery ?>
<?php
$images = get_field('personal_photos');
if( $images ):
?>
<?php foreach( $images as $image ): ?>
<div class="img">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<div class="img_caption"><?php echo $image['caption']; ?></div>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php // get form object data ?>
<?php
$post_object = get_field('case_study');
if( $post_object ):
$post = $post_object;
setup_postdata( $post );
?>
<a class="link" href="<?php the_permalink(); ?>">Read case study</a>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php // repeater fields ?>
<?php if (have_rows('highlights')): ?>
<?php while (have_rows('highlights')): the_row(); ?>
<div class="hero-highlight col6">
<h3 class="hero-highlight_headline"><?php the_sub_field('headline'); ?></h3>
<p class="hero-highlight_content"><?php the_sub_field('subheadline'); ?></p>
<a href="<?php get_permalink(the_sub_field('linked_page')); ?>" class="button"><?php the_sub_field('link_text'); ?></a>
</div>
<?php endwhile; ?>
<?php endif; ?>
@seanwash

Copy link
Copy Markdown
Author

Some helpful atom plugins for wordpress development: https://zach-adams.com/2015/05/best-atom-packages-for-wordpress-php-development/

@seanwash

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment