2017/01/26
固定ページ Wordpress
備忘録です。
固定ページ用のテンプレートを作成したものの、
固定ページのコンテンツで使っているショートコードが使えませんでした。
固定ページテンプレートでページを読み込む際のコードが原因でした。
<?php
$page_id = 2; //固定ページID
$content = get_post($page_id);
echo $content->post_content;
?>
これだとショートコードがそのまま([ショートコード])表示されてしまいます。
<?php $args = array( 'posts_per_page' => 1, 'post_type' => 'page', 'name' => 'testpage',//固定ページスラッグ ); ?> <?php $loop = new WP_Query( $args ); if($loop -> have_posts()): while($loop -> have_posts()): $loop -> the_post(); ?> <?php the_content(); ?> <?php endwhile; endif; ?><?php wp_reset_postdata(); ?>
2026/11/07
神社
2026/11/06
AI
2026/11/05
Wordpress
ホームページ制作
2026/11/04
Mac
2026/11/03
AI