Skip to content

Instantly share code, notes, and snippets.

@chocotaro
Created March 31, 2017 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chocotaro/5ccf49884a8fa5ccdacd5978e5146000 to your computer and use it in GitHub Desktop.
Save chocotaro/5ccf49884a8fa5ccdacd5978e5146000 to your computer and use it in GitHub Desktop.
新着記事表示の例(get_posts)
<dl>
<?php $newslist = get_posts('numberposts=0&category=1,2');
//numberposts=0で全ての記事、0以外で記事件数設定。category=カテゴリIDで指定カテゴリのみ表示(カンマ区切り)
foreach( $newslist as $post ):
setup_postdata( $post );
?>
<dt> <?php the_time('Y年n月j日'); ?></dt>
<dd> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a> </dd>
<?php endforeach; wp_reset_postdata(); ?>
</dl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment