Skip to content

Instantly share code, notes, and snippets.

@landru247
Created April 24, 2013 16:50
Show Gist options
  • Save landru247/5453644 to your computer and use it in GitHub Desktop.
Save landru247/5453644 to your computer and use it in GitHub Desktop.
WordPress: PHP ForEach Loop
<?php
$args = array( 'post_type' => '{cpt-name}', 'numberposts' => 4, '{taxomony-name}' => '{checked-item}' );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post);
?>
<?php endforeach; ?>
<?php
$args = array( 'post_type' => '{cpt-name}', 'numberposts' => 4, '{taxomony-name}' => '{checked-item}' );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post);
?>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment