いろんなget_postsのカタチ
// TYPE 1
<?php
$posts = get_posts('post_type=post&numberposts=-1');
foreach ($posts as $post): setup_postdata($post);
?>
<?php
endforeach;
wp_reset_query();
?>
// TYPE 2
<?php $args = array(
'name' => '[SLUG_NAME]',
'posts_per_page' => 1,
'post_type' => '[POST_TYPE]',
'[TAXONOMY NAME]' => '[TAXONOMY]'
);
$posts = get_posts($args);
foreach ($posts as $post): setup_postdata($post);
?>
<?php
endforeach;
wp_reset_query();
?>
<?php $args = array(
'numberposts' => 5,
//取得する投稿の数
'offset' => 0,
//先頭から何件の投稿を除外するか
'category' => ,
//指定したカテゴリID の投稿のみを返す。除外したい時は-を付ける
'orderby' => 'post_date',
//様々な値で並べ替える
'order' => 'DESC',
//$orderby でのソート方式。'ASC' - 昇順(低から高)。'DESC' - 降順(高から低)。
'include' => ,
//表示したい投稿のID
'exclude' => ,
//表示したくない投稿のID
'meta_key' => ,
'meta_value' => ,
//カスタムフィールドのキーと値を持つ投稿のみ表示。両方のパラメータ指定が必要
'post_type' => 'post',
//表示する投稿のタイプ。post、page、any(全て)等
'post_parent' => ,
//このIDの投稿の子のみを表示
'post_status' => 'publish'
//指定したステータスの投稿を表示
); ?>