下記のコードをfunctions.phpに追加する
function get_psttype_list( $atts ){
extract( shortcode_atts( array( // ショートコード引数の取得
'pt' => null ), $atts ));
$the_pt = get_post ( $pt );
$args = array(
'posts_per_page' => 5,
'post_type' => $pt,
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ): $the_query->the_post();
$psttype_list .= '' . get_the_title() . ' ';
endwhile;
return "".$psttype_list ."
";
}
add_shortcode('custompostlist', 'get_psttype_list');
//【custompostlist pt=”カスタム投稿名”】でテキストウィジェットに登録
//ショートコードをテキストウィジェットにペースト
//テキストモード・ビジュアルモードどちらでもO.K。