wp ループメモ コピペ用
<!-- お知らせエリア -->
<?php if(has_category('news')): ?>
<div><ul>
<?php$args = array(
'posts_per_page' => 1 // 表示件数の指定
);
$posts = get_posts( $args );foreach ( $posts as $post ): // ループの開始
setup_postdata( $post ); // 記事データの取得
?>
<li class="top-news"><a href="<?php the_permalink(); ?>"><time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('Y.m.d'); ?></time> <?php the_title(); ?></a></li><?php endforeach; // ループの終了
wp_reset_postdata(); // 直前のクエリを復元する?>
</ul><?php endif; ?>