Skip to content

Instantly share code, notes, and snippets.

@tomfinitely
Last active September 22, 2017 20:06
Show Gist options
  • Save tomfinitely/deab528b63e34e772a0461012908dd13 to your computer and use it in GitHub Desktop.
Save tomfinitely/deab528b63e34e772a0461012908dd13 to your computer and use it in GitHub Desktop.
ACF - Automated Recent Post Picker
<section class="row widget-area post-picker auto <?php the_sub_field( 'css_class' ); the_sub_field( 'background_selector' ); ?>" id="<?php the_sub_field ('block_id'); ?>" <?php if( get_sub_field( 'background_image' ) ) { ?> style="background-image: url(<?php the_sub_field( 'background_image' ); ?>);"<?php } ?> >
<div class="wrap">
<?php if( get_sub_field( 'headline' ) ) { ?>
<h3><?php the_sub_field( 'headline' ); ?></h3>
<?php } ?>
<section class="section news-post"><div class="box wrap">
<?php
$cat_ids = get_sub_field ( 'choose_category' );
//var_dump($cat_ids);
$args = array(
'post_type' => 'post',
'category__in' => (array) $cat_ids,
'posts_per_page' => 3,
);
$query = new WP_Query( $args );
?>
<?php if( $query->have_posts( ) ) : while( $query->have_posts( ) ) : $query->the_post( ); ?>
<article class="entry text-holder featuredpost one-third" itemtype="http://schema.org/BlogPosting" itemscope="itemscope">
<a href="<?php echo get_permalink(); ?>" class="entry-image">
<?php if( has_post_thumbnail( ) ) {
echo get_the_post_thumbnail( );
}
?></a>
<header class="entry-header">
<p class="entry-meta">
<?php echo do_shortcode("[post_date]"); ?>
</p>
<h2 class="entry-title"><a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?></a></h2>
</header>
<div class="entry-content">
<?php the_excerpt( ); ?>
<a href="<?php echo get_permalink(); ?>" class="button small more-link">Continue Reading</a>
</div>
</article>
<?php endwhile; endif; wp_reset_postdata(); ?>
</div><section>
</div></section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment