前言 當WordPress頁面都是用shortcode疊出來的時候,你的文章(post)也是需要變成shortcode的情況下才有辦法將它卡到頁面的某個地方,以下方式可以將你的文章(post)轉成shortcode的方式,讓你在頁面中可以方便的調用它!! 以下範例code,可以寫至theme目錄下的functions.php中 function home_post_listing_shortcode( $atts ) { ob_start(); <!--將query 到的資料存到$query--> $query = new WP_Query( array( 'post_type' => 'post', <!--post_type輸入你想要抓取的文章類型--> 'posts_per_page' => 3, <!--取出x筆數據--> 'order' => 'DSC', <