WordPressユーザーのbaserCMS覚え書き


現在のページが固定ページかどうかを判定する

WordPress

is_page()

関数リファレンス/is page - WordPress Codex 日本語版

baserCMS(3系)

$this->BcBaser->isPage()

[isPage] 現在のページが固定ページかどうかを判定する|baserCMS 3系関数リファレンス

メモ

baserCMSの $this->BcBaser->isPage() はWordPressの is_page() のように

<?php if ( is_page( 'foo' ) ) : ?>
    <!-- 現在のページのスラッグが foo であるときの処理 -->
<?php endif; ?>

といった、ページスラッグやページIDを引数として渡す書き方ができません。

特定の固定ページでのみ何かしらの処理をしたい場合は $this->BcBaser->getHere() を使い

<?php if ( preg_match( '/^\/foo$/', $this->BcBaser->getHere() ) ) : ?>
    <!-- ページURLが /foo だった場合の処理 -->
<?php endif; ?>

といった手法をとるとよいでしょう。