Skip to content

Instantly share code, notes, and snippets.

@IacopoC
Last active March 16, 2019 21:30
Show Gist options
  • Save IacopoC/b8914c78ac46f0ae33f0866b74deafda to your computer and use it in GitHub Desktop.
Save IacopoC/b8914c78ac46f0ae33f0866b74deafda to your computer and use it in GitHub Desktop.
ACF secondary loop news post type
<?php
$posts = get_posts(array(
'posts_per_page' => 3,
'post_type' => 'news'
));
if( $posts ): ?>
<ul>
<?php foreach( $posts as $post ):
setup_postdata( $post );
?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment