Created
March 31, 2017 01:28
-
-
Save chocotaro/5ccf49884a8fa5ccdacd5978e5146000 to your computer and use it in GitHub Desktop.
新着記事表示の例(get_posts)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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