固定ページや投稿の呼び出しはfunctions.phpに下記を記述
//固定ページをショートコードで呼び出す投稿記事内にこう→[page_echo id=1232]
function page_func($atts) {
extract(shortcode_atts(array(
'id' => 'defalt',
'post_type' => 'post',
'class' => 'defalt',
'show' => 'content',
), $atts));
$args = array(
'name' => $name,
'post_type' => $post_type,
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
if($show == 'title'){ //titleだったら「投稿タイトル」を表示させる
$content = get_the_title();
}else{//それ以外(デフォルト)だったら「投稿本文」を表示させる
$title = get_the_title();
$content = get_the_content();
}
//$content = preg_replace("/\n/","<br />",$content);
endwhile;
wp_reset_postdata();return '<div class="'. $class.'">' . $title . '' . $content . '</div>';
}add_shortcode( 'page_echo', 'page_func', true );
投稿ページ内にショートコードを記述(数字の箇所はページID)
[page_echo id=1232]
