[WordPress]get_postsテンプレ

get_postsテンプレ

$conditions = array(
    'post_type' => 'カスタム投稿タイプ',
    'posts_per_page' => -1,//-1:全て取得する
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'DESC',
    'tax_query' => array(
        array(
            'taxonomy' => 'タクソノミー',
            'field' => 'slug',
            'terms' => 'ターム',
        )
    ),
);
$posts = get_posts($conditions);
<?php foreach($posts as $post):?>
<?php endforeach; wp_reset_postdata();?>