静的ページにwordpressを埋め込む  WP_Query編

 

<?php require_once('./wp/wp-load.php'); ?>

<ul>
<?php
    $wp_query = new WP_Query();
    $param = array(
        'posts_per_page' => '5', //表示件数。-1なら全件表示
        'post_type' => 'post', //投稿タイプの名称を入れる
        'cat'=> 3,
        'post_status' => 'publish', //取得するステータス。publishなら一般公開のもののみ
        'orderby' => 'ID', //ID順に並び替え
        'order' => 'DESC'
    );
    $wp_query->query($param);
    if($wp_query->have_posts()): while($wp_query->have_posts()) : $wp_query->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php echo get_post_time('Y年m月d日', true); ?> <?php the_title(); ?></a></li>
<?php endwhile; endif; wp_reset_query(); ?>
</ul>