Next and previous page links – WortGepresst



STARTSEITE MULTIMEDIA WORTGEPRESST FAMILIENBANDE BOOKMARK PRIVACY


Next and previous page links

The previous_post_link() and next_post_link() template tags take four optional parameters:

  • format– This is the text displayed before or after the link. The default value is‘« %link’.
  • link– This is the link text. The default value is the post title (%title).
  • in_same_term – This is a Boolean (true/false) parameter that indicates whether the linked post must be in the same taxonomy as the current post. For example, if this parameter is true and the current post is in the how to category, the linked posts will be the previous and next posts in the how to category. If there isn’t a previous or next post in the category, a link won’t be displayed. The default value is false.
  • taxonomy– This is the specified taxonomy if in_same_term is true. The default value is category.

Let’s make some changes to our previous and next links. First, we’ll assume that visitors interested in technical how-to articles aren’t at our site to read about recipes or dog grooming, so let’s change in_same_term to true. Since the default value for taxonomy is category, we can leave that as is. We’ll also add some space between the two links and a vertical separator character. Our updated template tags look like this:

Here is how the links generated by the updated code are displayed on our site:
<< How to edit | How to clear >>
For more information, seeprevious_post_link andnext_post_link in the WordPress documentation.

Font Resize
Contrast
Zur Werkzeugleiste springen