サイドバーやトップページでカスタム投稿の記事も合わせて新着記事を表示したいときに
<ul> <?php global $post; $mypost = get_posts( array( 'numberposts' => 5, 'post_type' => array('post','info' )); foreach( $mypost as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> <?php wp_reset_postdata(); ?>
numberposts は表示件数
post_type に 投稿タイプを指定
order : 並び順 ASC , DESC
get_posts のパラメーターはこちらが参考
http://elearn.jp/wpman/function/get_posts.html