To enable interlinking between pages, LPagery provides a shortcode lpagery_link. This shortcode generates an HTML anchor element (<a>) linking to the specified page. The generated anchor element always includes the class lpagery_link_anchor.
Linking by Page Position #
Use the following shortcode to link pages based on their positions within the sheet:
[lpagery_link position="NEXT" title="Next" circle=true target="_blank"]
Parameters: #
- position: Determines the page to link to based on its position.
- FIRST: Links to the first page created in the sheet.
- LAST: Links to the last page created in the sheet.
- NEXT: Links to the next page created in the sheet.
- PREV: Links to the previous page created in the sheet.
- circle:
- true/yes: When enabled, it loops back to the first page after the last page and vice versa.
- title:
- If set, this title will be used as the link’s title. Otherwise, the title of the linked page will be used. Placeholders can be used here as well
- target:
- Specifies the target attribute of the anchor element. Valid values are: _blank, _self, _parent, _top.
Linking by Slug #
LPagery also allows linking to pages based on their slug. This can be achieved as follows:
Assume the following input data:
city | link_to | link_title |
Hamburg | berlin | Page of Berlin |
Berlin | hamburg | Page of Hamburg |
Munich | berlin | Page of Berlin |
And the following shortcode in the template page:
[lpagery_link slug="{link_to}" title="{link_title}"]
This would result in the following links on the respective pages:
- On the Hamburg and Munich pages:
[lpagery_link slug="berlin" title="Page of Berlin"]
Resulting in
<a class=”lpagery_link_anchor” href=”https://yoursite.example/berlin/” target=”_self”>Page of Berlin</a>
- On the Berlin page:
[lpagery_link slug="hamburg" title="Page of Hamburg"]
Resulting in
<a class=”lpagery_link_anchor” href=”https://yoursite.example/hamburg/” target=”_self”>Page of Hamburg</a>
You can also hardcode values directly. It is crucial that the resulting slug corresponds to an existing page.