Skip to content

Instantly share code, notes, and snippets.

@megane9988
Created August 22, 2016 06:09
Show Gist options
  • Save megane9988/8d2a377235ee8518bd9154b6039fb9b8 to your computer and use it in GitHub Desktop.
Save megane9988/8d2a377235ee8518bd9154b6039fb9b8 to your computer and use it in GitHub Desktop.
get_postsで基本のループ
<ul>
<?php
$args = array( 'posts_per_page' => 5, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment