functions に
function post_list($atts, $content = null) { extract(shortcode_atts(array( "ex" => '', "type" => '' ), $atts)); global $post; $myposts = get_posts('numberposts=-1&order=ASC&post_type='.$type.'&exclude='.$ex); $retour='<ul>'; foreach($myposts as $post) : setup_postdata($post); $retour.='<li><a href="'.get_permalink().'">'.the_title("","",false).'</a></li>'; endforeach;wp_reset_postdata(); $retour.='</ul> '; return $retour; } add_shortcode("list", "post_list");
ショートコードは list type=”custom_post_type” ex=”10″ のように。
カスタム投稿タイプのトップページを編集しやすいようindex.html を作成したので、それを除外するよう ex を設定。