WordPressユーザーのbaserCMS覚え書き


次の記事へのリンクを出力する

WordPress

next_post_link()

テンプレートタグ/next post link - WordPress Codex 日本語版

baserCMS(3系)

$this->Blog->nextLink( $post , [$title] , [$htmlAttributes] )

[nextLink] 次の記事へのリンクを出力する|baserCMS 3系関数リファレンス

メモ

WordPressの個別ページ(通常 single.php)では next_post_link() をループ内で用いる必要があります。一方、baserCMSの場合、個別ページ(通常 single.php)ではWordPressに見られるような

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- 記事がある場合の表示 -->
<?php endwhile; ?>
<?php else: ?>
<!-- 記事がない場合の表示 -->
<?php endif; ?>

といったループを組む必要がないため、

<?php $this->Blog->nextLink($post) ?>

と書くだけで、個別ページ内の任意の位置に nextLink() を組み込むことが可能です。