posts_nav_link

Sponsored Link

次と前のページのためにリンクを表示します。 インデックス、カテゴリー、およびアーカイブページのナビゲーションを”paged”で提供するために役に立ちます。

記事の横に前のページを表示するには、next_posts_linkとprevious_posts_link()を参照してください。

個々のポストに次で前のポストナビゲーションを表示するには、next_post_link()とprevious_post_link()を参照してください。

Sponsored Link

Displays links for next and previous pages. Useful for providing “paged” navigation of index, category and archive pages.

For displaying next and previous pages of posts see next_posts_link and previous_posts_link().

For displaying next and previous post navigation on individual posts, see next_post_link() and previous_post_link().

posts_nav_linkのテンプレートタグ使用方法

<?php posts_nav_link('sep','prelabel','nxtlabel'); ?>

ブログの投稿は、伝統的なものから順(上部にある最新の投稿)に記載されて以来、そこに 「次のページ」の定義にいくつかのあいまいさがあるので注意してください。WordPresは”過去に向かった次のページ”として”next page”を定義します。WordPres1.5では、デフォルトのKubrickのテーマは”previous entries”の”next page”のリンクをラベルにすることによってこのあいまいさを解決します。例を見てください: Kubrickのテーマ形式。

Note that since weblog posts are traditionally listed in reverse chronological order (with most recent posts at the top), there is some ambiguity in the definition of “next page”. WordPress defines “next page” as the “next page toward the past”. In WordPress 1.5, the default Kubrick theme addresses this ambiguity by labeling the “next page” link as “previous entries”. See Example: Kubrick Theme Format.

デフォルトの使い方

デフォルトで、posts_nav_linkはこれに似ています:

By default, the posts_nav_link look like this:

≪ Previous Page Next Page ≫

<?php posts_nav_link(); ?>

DIVを中心で

前次のページリンク(“previous page ・ next page”)はページの中央に表示されます。

⇒Displays previous and next page links (“previous page ・ next page”) centered on the page.

<div style="text-align:center;">
<?php posts_nav_link(' &amp;#183; ', 'previous page', 'next page'); ?>
</div>

画像を使用する方法

<?php posts_nav_link(' ', '<img src="images/prev.jpg" />', '<img src="images/next.jpg" />'); ?>

Kubrickのテーマ形式

Kubrickのテーマ形式は投稿ナビゲーションにフォーマットします。 Kubrickのテーマの形式は投稿ナビゲーションにすることで、この方法がフォーマットされました。しかしながら、posts_nav_link を使用する事は、この方法では予期しない動作や例えば不適切なセッションにリンクしている前後のリンクが二重に並べられるなどが起こるでしょう。
Kubrickのテーマは、実際にnext_posts_link と previous_posts_link()を使用します。

The Kubrick theme format for posts navigation, could be formatted this way. However, using posts_nav_link in this way will result in unintended behavior, such as double stacked next and previous links that link to the incorrect sections.

The Kubrick Theme actually uses next_posts_link and previous_posts_link().

<div class="navigation">
<div class="alignleft"><?php posts_nav_link('','','&amp;laquo; Previous Entries') ?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &amp;raquo;','') ?></div>
</div>

リンクテキストのカスタマイズする方法

各リンクとリンク間のテキストを変更することができます。

You can change the text in each of the links and in the text in between the links.

<p><?php posts_nav_link(' or ', 'You can go back
 to the previous page', 'you can go 
forward to the next page'); ?>.</p>

posts_nav_linkのパラメーター

sep

(string)テキストは、リンクの間に表示されます。

(string) Text displayed between the links.

  • Defaults to ‘ :: ‘ in 1.2.x.
  • Defaults to ‘ 窶・’ in 1.5.

prelabel

(string) 前のページのリンクテキスト。

(string) Link text for the previous page.

  • Defaults to ‘<< Previous Page' in 1.2.x.
  • Defaults to ‘≪ Previous Page’ in 1.5.

nxtlabel

(string)次のページのリンクテキスト。

(string) Link text for the next page.

  • Defaults to ‘Next Page >>’ in 1.2.x.
  • Defaults to ‘Next Page ≫’ in 1.5

リソース

  • Digging into WordPress – Definitive Guide to WordPress Page Navigation

関連テンプレートタグ

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, wp_link_pages, next_post_link, next_posts_link, previous_post_link, previous_posts_link, posts_nav_link, sticky_class, the_meta

Sponsored Link