<!--
	This source file is part of the open source project
	ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide)

	@link      https://expressionengine.com/
	@copyright Copyright (c) 2003-2021, Packet Tide, LLC. (https://packettide.com)
	@license   https://expressionengine.com/license Licensed under Apache License, Version 2.0
-->
<!DOCTYPE html>
<html lang="en" dir="ltr">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">

		<title>Pagination — ExpressionEngine 5.4.2 Documentation</title>

		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />

		<link rel="stylesheet" href="../_assets/default.min.css?v=3">

		<!-- Favicons -->
		<link rel="apple-touch-icon" sizes="180x180" href="../_assets/images/favicons/apple-touch-icon.png">
		<link rel="icon" type="image/png" sizes="32x32" href="../_assets/images/favicons/favicon-32x32.png">
		<link rel="icon" type="image/png" sizes="16x16" href="../_assets/images/favicons/favicon-16x16.png">
		<link rel="manifest" href="../_assets/images/favicons/site.webmanifest">
		<link rel="mask-icon" href="../_assets/images/favicons/safari-pinned-tab.svg" color="#2e6abd">
		<link rel="shortcut icon" href="../_assets/images/favicons/favicon.ico">
		<meta name="msapplication-TileColor" content="#2e6abd">
		<meta name="msapplication-config" content="../_assets/images/favicons/browserconfig.xml">
		<meta name="theme-color" content="#ffffff">

		<style>.sidebar-toc { visibility: hidden; }</style>
		<noscript><style>.sidebar-toc { visibility: visible; }</style></noscript>
	</head>
	<body>

		<div class="header">
			<div class="header-content">
				<a href="https://docs.expressionengine.com/latest" class="header-logo"><img src="../_assets/images/ee-logo-white.svg" alt=""></a>
				<a href="https://docs.expressionengine.com/latest" class="header-title">ExpressionEngine Docs</a>

				<nav>
					<a href="https://u.expressionengine.com" class="hide font-monospace">{ee:u}</a>
					<a href="https://expressionengine.com/forums" class="hide">Forums</a>

					<div class="version-button-wrapper">
					<div class="dropdown">
							<a class="" href="#">v5<span class="i-arrow-down"></span></a>
							<div class="dropdown-menu">
								<div class="dropdown-menu-inner">
									<a href="https://docs.expressionengine.com/latest/">v6</a>
									<a class="active" href="https://docs.expressionengine.com/v5/">v5</a>
									<a href="https://docs.expressionengine.com/v4/">v4</a>
									<a href="https://docs.expressionengine.com/v3/">v3</a>
									<a href="https://docs.expressionengine.com/v2/">v2</a>
									<a href="https://docs.expressionengine.com/v1/">v1</a>
								</div>
							</div>
						</div>
						<a href="https://docs.expressionengine.com/downloads/v5" class="download-button"><img src="../_assets/images/download.svg" alt=""></a>
					</div>
				</nav>

				<div class="hamburger mobile-menu-button" onclick="toggleMobileMenu();">
					<span></span><span></span><span></span>
				</div>
			</div>
		</div>

		<div class="sidebar-container">
			<div class="sidebar">
				<div class="sidebar-search">
				<input type="text" class="search-input" id="docsearch-input" name="search" placeholder="Search">
					<!-- <div class="sidebar-sponsor">
						<p>Sponsored By:</p><img src="" alt="">
					</div> -->
				</div>

				<div class="sidebar-toc">
					<ul><li  class=""><a href="../index.html">Welcome</a></li><li  class=""><a >Installation & Updates</a><ul><li  class=""><a href="../installation/requirements.html">System Requirements</a></li><li  class=""><a href="../installation/installation.html">Installation</a></li><li  class=""><a href="../installation/best-practices.html">Best Practices</a></li><li  class=""><a href="../installation/updating.html">Updating</a></li><li  class=""><a href="../installation/changelog.html">Change Log</a></li></ul></li><li  class=""><a >Getting Started</a><ul><li  class=""><a href="../getting-started/the-big-picture.html">The Big Picture</a></li><li  class=""><a href="../getting-started/ten-minute-primer.html">10 Minute Primer</a></li></ul></li><li  class=""><a >General Information</a><ul><li  class=""><a href="../general/url-structure.html">URL Structure</a></li><li  class=""><a href="../general/404pages.html">404 Pages</a></li><li  class=""><a href="../general/database-backup.html">Backing Up Your Site</a></li><li  class=""><a href="../general/moving.html">Moving to Another Server</a></li><li  class=""><a href="../general/gdpr.html">GDPR Compliance</a></li><li  class=""><a href="../general/cookies.html">Cookies</a></li><li  class=""><a href="../general/date-localization.html">Date Localization</a></li><li  class=""><a href="../general/languages.html">Language Packs</a></li><li  class=""><a href="../general/system-configuration-overrides.html">System Config Overrides</a></li><li  class=""><a href="../general/text-formatting.html">Text Formatting</a></li><li  class=""><a href="../general/converting-to-innodb.html">Converting to InnoDB</a></li><li  class=""><a href="../general/bbcode.html">BBCode Reference</a></li><li  class=""><a href="../general/reserved-words.html">Reserved Words</a></li><li  class=""><a href="../general/member-import-xml-format.html">Member XML Format</a></li></ul></li><li  class="active"><a >Templates</a><ul><li  class=""><a href="../templates/overview.html">Overview</a></li><li  class=""><a href="../templates/language.html">Template Language</a></li><li  class=""><a href="../templates/conditionals.html">Conditional Tags</a></li><li  class=""><a href="../templates/embedding.html">Embedding Templates</a></li><li  class=""><a href="../templates/layouts.html">Template Layouts</a></li><li  class=""><a href="../templates/partials.html">Template Partials</a></li><li  class=""><a href="../templates/variable.html">Template Variables</a></li><li  class=""><a >Global Template Variables</a><ul><li  class=""><a href="../templates/globals/single-variables.html">Single Global Variables</a></li><li  class=""><a href="../templates/globals/stylesheet.html">Linking to Stylesheets</a></li><li  class=""><a href="../templates/globals/url-segments.html">URL Segment Variables</a></li><li  class=""><a href="../templates/globals/consent.html">Consent Variables</a></li><li  class=""><a href="../templates/globals/path.html">Path Variables</a></li><li  class=""><a href="../templates/globals/preload-replacement.html">Preload Text Replacements</a></li></ul></li><li  class=""><a href="../templates/variable-modifiers.html">Variable Modifiers</a></li><li  class=""><a href="../templates/date-variable-formatting.html">Date Variable Formatting</a></li><li  class=""><a href="../templates/routes.html">Template Routes</a></li><li data-active-page="true" class="active"><a href="../templates/pagination.html">Pagination</a></li><li  class=""><a href="../templates/engine.html">The Template Engine</a></li></ul></li><li  class=""><a >Channels</a><ul><li  class=""><a href="../channels/entries.html">Entries Tag</a></li><li  class=""><a href="../channels/info.html">Channel Information Tag</a></li><li  class=""><a href="../channels/entry-linking.html">Next/Previous Entries</a></li><li  class=""><a href="../channels/entry-spanning.html">Spanning Across Pages</a></li><li  class=""><a href="../channels/entry-tracking.html">Entry Views Tracking</a></li><li  class=""><a href="../channels/dynamic-parameters.html">Dynamic Parameters</a></li><li  class=""><a href="../channels/categories.html">Categories Tag</a></li><li  class=""><a href="../channels/category-archive.html">Category Archive Tag</a></li><li  class=""><a href="../channels/category-heading.html">Category Heading Tag</a></li><li  class=""><a href="../channels/archive-months.html">Archive Month Links</a></li><li  class=""><a href="../channels/sets.html">Channel Sets</a></li><li  class=""><a href="../channels/calendar.html">Calendar Tag</a></li><li  class=""><a >Channel Form</a><ul><li  class=""><a href="../channels/channel-form/overview.html">Channel Form Tag</a></li><li  class=""><a href="../channels/channel-form/examples.html">Examples</a></li><li  class=""><a href="../channels/channel-form/inputs.html">Form Inputs</a></li><li  class=""><a href="../channels/channel-form/fields.html">Other Fields</a></li><li  class=""><a href="../channels/channel-form/status.html">Status Selection</a></li><li  class=""><a href="../channels/channel-form/categories.html">Category Selection</a></li><li  class=""><a href="../channels/channel-form/development.html">Development</a></li></ul></li></ul></li><li  class=""><a >Comments</a><ul><li  class=""><a href="../comment/overview.html">Overview</a></li><li  class=""><a href="../comment/entries.html">Entries Tag</a></li><li  class=""><a href="../comment/form.html">Submission Form</a></li><li  class=""><a href="../comment/subscriptions.html">Subscriptions</a></li><li  class=""><a href="../comment/control-panel.html">Control Panel</a></li></ul></li><li  class=""><a >Add-Ons</a><ul><li  class=""><a href="../add-ons/overview.html">Overview</a></li><li  class=""><a href="../add-ons/blacklist.html">Blacklist / White List</a></li><li  class=""><a href="../add-ons/consent.html">Consent</a></li><li  class=""><a href="../add-ons/email.html">Email</a></li><li  class=""><a href="../add-ons/emoji.html">Emoji</a></li><li  class=""><a href="../add-ons/file.html">File</a></li><li  class=""><a >Discussion Forum</a><ul><li  class=""><a href="../add-ons/forum/index.html">Overview</a></li><li  class=""><a href="../add-ons/forum/setup.html">Setup</a></li><li  class=""><a href="../add-ons/forum/boards.html">Boards</a></li><li  class=""><a href="../add-ons/forum/themes.html">Themes</a></li><li  class=""><a href="../add-ons/forum/global-variables.html">Global Variables</a></li><li  class=""><a href="../add-ons/forum/user-management.html">User Management</a></li><li  class=""><a href="../add-ons/forum/channel-forum.html">Associating Channel Entries with Forum Topics</a></li><li  class=""><a href="../add-ons/forum/recent-topics.html">Recent Forum Topics</a></li><li  class=""><a href="../add-ons/forum/signatures.html">Signatures and Avatars</a></li><li  class=""><a href="../add-ons/forum/helper.html">Helper</a></li><li  class=""><a href="../add-ons/forum/other-features.html">Other Features</a></li></ul></li><li  class=""><a href="../add-ons/http-header.html">HTTP Header</a></li><li  class=""><a href="../add-ons/ip-to-nation.html">IP to Nation</a></li><li  class=""><a href="../add-ons/metaweblog-api.html">Metaweblog API</a></li><li  class=""><a href="../add-ons/moblog.html">Moblog</a></li><li  class=""><a href="../add-ons/pages.html">Pages</a></li><li  class=""><a href="../add-ons/query.html">Query</a></li><li  class=""><a href="../add-ons/rss.html">RSS</a></li><li  class=""><a href="../add-ons/rss-parser.html">RSS Parser</a></li><li  class=""><a href="../add-ons/rte.html">Rich Text Editor</a></li><li  class=""><a >Search</a><ul><li  class=""><a href="../add-ons/search/index.html">Overview</a></li><li  class=""><a href="../add-ons/search/simple.html">Simple Form Tag</a></li><li  class=""><a href="../add-ons/search/advanced.html">Advanced Form Tag</a></li><li  class=""><a href="../add-ons/search/results.html">Displaying Results</a></li></ul></li><li  class=""><a >Simple Commerce</a><ul><li  class=""><a href="../add-ons/simple-commerce/index.html">Overview</a></li><li  class=""><a href="../add-ons/simple-commerce/control-panel.html">Control Panel</a></li><li  class=""><a href="../add-ons/simple-commerce/email-templates.html">Email Templates</a></li><li  class=""><a href="../add-ons/simple-commerce/ipn.html">Instant Payment Notification</a></li><li  class=""><a href="../add-ons/simple-commerce/items.html">Managing Store Items</a></li><li  class=""><a href="../add-ons/simple-commerce/paypal-settings.html">PayPal Settings</a></li><li  class=""><a href="../add-ons/simple-commerce/purchases.html">Managing Store Purchases</a></li></ul></li><li  class=""><a href="../add-ons/spam.html">Spam</a></li><li  class=""><a href="../add-ons/statistics.html">Statistics</a></li><li  class=""><a href="../add-ons/emoticon.html">Emoticon (Deprecated)</a></li></ul></li><li  class=""><a >Fieldtypes</a><ul><li  class=""><a href="../fieldtypes/overview.html">Overview</a></li><li  class=""><a href="../fieldtypes/date.html">Date</a></li><li  class=""><a href="../fieldtypes/duration.html">Duration</a></li><li  class=""><a href="../fieldtypes/email-address.html">Email Address</a></li><li  class=""><a href="../fieldtypes/file.html">File</a></li><li  class=""><a href="../fieldtypes/file-grid.html">File Grid</a></li><li  class=""><a href="../fieldtypes/fluid.html">Fluid</a></li><li  class=""><a href="../fieldtypes/grid.html">Grid</a></li><li  class=""><a href="../fieldtypes/relationships.html">Relationships</a></li><li  class=""><a href="../fieldtypes/rte.html">Rich Text Editor</a></li><li  class=""><a href="../fieldtypes/select.html">Checkboxes, Radio Buttons, Select, Multiselect</a></li><li  class=""><a href="../fieldtypes/text.html">Text Input</a></li><li  class=""><a href="../fieldtypes/textarea.html">Textarea</a></li><li  class=""><a href="../fieldtypes/toggle.html">Toggle</a></li><li  class=""><a href="../fieldtypes/url.html">URL</a></li></ul></li><li  class=""><a href="../member/index.html">Member Management</a></li><li  class=""><a >Control Panel</a><ul><li  class=""><a href="../control-panel/index.html">The Control Panel</a></li><li  class=""><a href="../control-panel/overview.html">CP Overview</a></li><li  class=""><a href="../control-panel/create.html">Create</a></li><li  class=""><a href="../control-panel/channels.html">Channels</a></li><li  class=""><a href="../control-panel/entry-manager.html">Entry Manager</a></li><li  class=""><a href="../control-panel/file-manager.html">File Manager</a></li><li  class=""><a href="../control-panel/field-manager.html">Field Manager</a></li><li  class=""><a href="../control-panel/member-manager.html">Member Manager</a></li><li  class=""><a href="../control-panel/member-profile.html">Member Profile</a></li><li  class=""><a href="../control-panel/template-manager.html">Template Manager</a></li><li  class=""><a href="../control-panel/addons-manager.html">Add-On Manager</a></li><li  class=""><a href="../control-panel/categories.html">Categories</a></li><li  class=""><a href="../control-panel/utilities.html">Utilities</a></li><li  class=""><a href="../control-panel/system-logs.html">System Logs</a></li><li  class=""><a >System Settings</a><ul><li  class=""><a href="../control-panel/settings/index.html">Overview</a></li><li  class=""><a href="../control-panel/settings/general.html">General Settings</a></li><li  class=""><a href="../control-panel/settings/avatars.html">Avatar</a></li><li  class=""><a href="../control-panel/settings/captcha.html">CAPTCHA</a></li><li  class=""><a href="../control-panel/settings/comments.html">Comment</a></li><li  class=""><a href="../control-panel/settings/content-design.html">Content & Design</a></li><li  class=""><a href="../control-panel/settings/consents.html">Consents</a></li><li  class=""><a href="../control-panel/settings/debug-output.html">Debugging & Output</a></li><li  class=""><a href="../control-panel/settings/email.html">Outgoing Email</a></li><li  class=""><a href="../control-panel/settings/hit-tracking.html">Hit Tracking</a></li><li  class=""><a href="../control-panel/settings/members.html">Member</a></li><li  class=""><a href="../control-panel/settings/messages.html">Messaging</a></li><li  class=""><a href="../control-panel/settings/security-privacy.html">Security & Privacy</a></li><li  class=""><a href="../control-panel/settings/template.html">Template</a></li><li  class=""><a href="../control-panel/settings/throttling.html">Access Throttling</a></li><li  class=""><a href="../control-panel/settings/urls.html">URL and Path</a></li><li  class=""><a href="../control-panel/settings/word-censor.html">Word Censorship</a></li><li  class=""><a href="../control-panel/settings/html-buttons.html">HTML Buttons</a></li><li  class=""><a href="../control-panel/settings/menu-manager.html">Menu Manager</a></li></ul></li><li  class=""><a href="../control-panel/footer.html">CP Footer</a></li></ul></li><li  class=""><a >Security</a><ul><li  class=""><a href="../security/general-tips.html">Tips</a></li><li  class=""><a href="../security/captchas.html">Captchas</a></li><li  class=""><a href="../security/spam-protection.html">Spam Protection</a></li></ul></li><li  class=""><a >Optimization</a><ul><li  class=""><a href="../optimization/caching.html">Caching and Performance</a></li><li  class=""><a href="../optimization/handling-extreme-traffic.html">Handling Extreme Traffic</a></li><li  class=""><a href="../optimization/throttling.html">Throttling</a></li><li  class=""><a href="../optimization/new-relic.html">New Relic Performance Monitoring</a></li></ul></li><li  class=""><a >Multiple Sites</a><ul><li  class=""><a href="../msm/overview.html">Overview</a></li><li  class=""><a href="../msm/code.html">Variables and Parameter</a></li></ul></li><li  class=""><a >Troubleshooting</a><ul><li  class=""><a href="../troubleshooting/general.html">General</a></li><li  class=""><a href="../troubleshooting/installation.html">Installation</a></li><li  class=""><a href="../troubleshooting/templates.html">Templates</a></li><li  class=""><a href="../troubleshooting/control-panel.html">Control Panel</a></li><li  class=""><a href="../troubleshooting/channels-and-entries.html">Channels and Entries</a></li><li  class=""><a href="../troubleshooting/email.html">Email</a></li><li  class=""><a href="../troubleshooting/simple-commerce-module.html">Simple Commerce Module</a></li><li  class=""><a href="../troubleshooting/error-messages.html">Error Messages</a></li></ul></li><li  class=""><a >Add-On Development</a><ul><li  class=""><a href="../development/addon-setup-php-file.html">The addon.setup.php File</a></li><li  class=""><a href="../development/plugins.html">Plugins</a></li><li  class=""><a href="../development/modules.html">Modules</a></li><li  class=""><a href="../development/extensions.html">Extensions</a></li><li  class=""><a >Extension Hooks</a><ul><li  class=""><a >Global</a><ul><li  class=""><a href="../development/extension-hooks/global/core.html">Core Library</a></li><li  class=""><a href="../development/extension-hooks/global/email.html">Email Library</a></li><li  class=""><a href="../development/extension-hooks/global/filemanager.html">Filemanager Library</a></li><li  class=""><a href="../development/extension-hooks/global/functions.html">Functions Library</a></li><li  class=""><a href="../development/extension-hooks/global/grid.html">Grid Fieldtype</a></li><li  class=""><a href="../development/extension-hooks/global/input.html">Input Library</a></li><li  class=""><a href="../development/extension-hooks/global/member-model.html">Legacy Member Model</a></li><li  class=""><a href="../development/extension-hooks/global/output.html">Output Library</a></li><li  class=""><a href="../development/extension-hooks/global/pagination.html">Pagination Library</a></li><li  class=""><a href="../development/extension-hooks/global/relationships.html">Relationships Fieldtype</a></li><li  class=""><a href="../development/extension-hooks/global/session.html">Session Library</a></li><li  class=""><a href="../development/extension-hooks/global/template.html">Template Library</a></li><li  class=""><a href="../development/extension-hooks/global/text-helper.html">Text Helper</a></li><li  class=""><a href="../development/extension-hooks/global/typography.html">Typography Library</a></li></ul></li><li  class=""><a >API Libraries</a><ul><li  class=""><a href="../development/extension-hooks/api/channel-fields.html">Channel Fields API</a></li><li  class=""><a href="../development/extension-hooks/api/template-structure.html">Template Structure API</a></li></ul></li><li  class=""><a >Control Panel</a><ul><li  class=""><a href="../development/extension-hooks/cp/admin-content.html">Admin Content Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/css.html">CSS Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/design.html">Design Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/javascript.html">Javascript Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/login.html">Login Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/members.html">Members Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/menu.html">Control Panel Menu</a></li><li  class=""><a href="../development/extension-hooks/cp/myaccount.html">My Account Controller</a></li><li  class=""><a href="../development/extension-hooks/cp/publish.html">Publish Controller</a></li></ul></li><li  class=""><a >Models</a><ul><li  class=""><a href="../development/extension-hooks/model/category-field.html">CategoryField Model</a></li><li  class=""><a href="../development/extension-hooks/model/category-group.html">CategoryGroup Model</a></li><li  class=""><a href="../development/extension-hooks/model/category.html">Category Model</a></li><li  class=""><a href="../development/extension-hooks/model/channel.html">Channel Model</a></li><li  class=""><a href="../development/extension-hooks/model/channel-entry.html">Channel Entry Model</a></li><li  class=""><a href="../development/extension-hooks/model/channel-field-group.html">ChannelFieldGroup Model</a></li><li  class=""><a href="../development/extension-hooks/model/channel-field.html">ChannelField Model</a></li><li  class=""><a href="../development/extension-hooks/model/channel-form-settings.html">ChannelFormSettings Model</a></li><li  class=""><a href="../development/extension-hooks/model/channel-layout.html">ChannelLayout Model</a></li><li  class=""><a href="../development/extension-hooks/model/comment.html">Comment Model</a></li><li  class=""><a href="../development/extension-hooks/model/file.html">File Model</a></li><li  class=""><a href="../development/extension-hooks/model/template-global-variable.html">GlobalVariable Model</a></li><li  class=""><a href="../development/extension-hooks/model/member-field.html">MemberField Model</a></li><li  class=""><a href="../development/extension-hooks/model/member-group.html">MemberGroup Model</a></li><li  class=""><a href="../development/extension-hooks/model/member.html">Member Model</a></li><li  class=""><a href="../development/extension-hooks/model/site.html">Site Model</a></li><li  class=""><a href="../development/extension-hooks/model/template-snippet.html">Snippet Model</a></li><li  class=""><a href="../development/extension-hooks/model/template-specialty-template.html">SpecialityTemplate Model</a></li><li  class=""><a href="../development/extension-hooks/model/status.html">Status Model</a></li><li  class=""><a href="../development/extension-hooks/model/template-group.html">TemplateGroup Model</a></li><li  class=""><a href="../development/extension-hooks/model/template-route.html">TemplateRoute Model</a></li><li  class=""><a href="../development/extension-hooks/model/template.html">Template Model</a></li></ul></li><li  class=""><a >Modules</a><ul><li  class=""><a href="../development/extension-hooks/module/channel.html">Channel Module</a></li><li  class=""><a href="../development/extension-hooks/module/channel-form.html">Channel Form</a></li><li  class=""><a href="../development/extension-hooks/module/comment.html">Comment Module</a></li><li  class=""><a href="../development/extension-hooks/module/email.html">Email Module</a></li><li  class=""><a href="../development/extension-hooks/module/forum.html">Forum Module</a></li><li  class=""><a href="../development/extension-hooks/module/member.html">Member Module</a></li><li  class=""><a href="../development/extension-hooks/module/member-auth.html">Member Module Authorization</a></li><li  class=""><a href="../development/extension-hooks/module/member-register.html">Member Module Registration</a></li><li  class=""><a href="../development/extension-hooks/module/member-settings.html">Member Module Settings</a></li><li  class=""><a href="../development/extension-hooks/module/search.html">Search Module</a></li><li  class=""><a href="../development/extension-hooks/module/simple-commerce.html">Simple Commerce Module</a></li><li  class=""><a href="../development/extension-hooks/module/wiki.html">Wiki Module</a></li></ul></li></ul></li><li  class=""><a href="../development/fieldtypes.html">Fieldtypes</a></li><li  class=""><a href="../development/architecture.html">Architecture</a></li><li  class=""><a >Services</a><ul><li  class=""><a href="../development/services/addon.html">Addon Service</a></li><li  class=""><a href="../development/services/alert.html">CP/Alert Service</a></li><li  class=""><a href="../development/services/config.html">Config Service</a></li><li  class=""><a href="../development/services/consent.html">Consent Service</a></li><li  class=""><a href="../development/services/cookie.html">Cookie</a></li><li  class=""><a href="../development/services/csv.html">CSV Library</a></li><li  class=""><a href="../development/services/encrypt.html">Encrypt Service</a></li><li  class=""><a href="../development/services/event.html">Event Service</a></li><li  class=""><a href="../development/services/filepicker.html">CP/FilePicker Service</a></li><li  class=""><a href="../development/services/filter.html">CP/Filter Service</a></li><li  class=""><a >Format Service</a><ul><li  class=""><a href="../development/services/format.html">Format</a></li><li  class=""><a href="../development/services/format/number.html">Number Formatter</a></li><li  class=""><a href="../development/services/format/text.html">Text Formatter</a></li></ul></li><li  class=""><a href="../development/services/ipaddress.html">IP Address Service</a></li><li  class=""><a href="../development/services/live-preview.html">LivePreview Service</a></li><li  class=""><a href="../development/services/memory.html">Memory Service</a></li><li  class=""><a href="../development/services/modal.html">CP/Modal Service</a></li><li  class=""><a >Model Service</a><ul><li  class=""><a href="../development/services/model.html">Model</a></li><li  class=""><a href="../development/services/model/fetching.html">Fetching Models</a></li><li  class=""><a href="../development/services/model/relationships.html">Relationships</a></li><li  class=""><a href="../development/services/model/collection.html">Collections</a></li><li  class=""><a href="../development/services/model/building-your-own.html">Building your own Models</a></li><li  class=""><a href="../development/services/model/relating-models.html">Relating Models</a></li></ul></li><li  class=""><a href="../development/services/pagination.html">CP/Pagination Service</a></li><li  class=""><a href="../development/services/permission.html">Permission Service</a></li><li  class=""><a href="../development/services/sidebar.html">CP/Sidebar Service</a></li><li  class=""><a href="../development/services/spam.html">Spam Service</a></li><li  class=""><a href="../development/services/table.html">CP/Table Service</a></li><li  class=""><a href="../development/services/url.html">CP/URL Service</a></li><li  class=""><a href="../development/services/validation.html">Validation Service</a></li><li  class=""><a href="../development/services/view.html">View Service</a></li></ul></li><li  class=""><a href="../development/tree-datastructure.html">Tree Datastructure</a></li><li  class=""><a href="../development/shared-form-view.html">Shared Form View</a></li><li  class=""><a href="../development/rte-tools.html">RTE Tools API</a></li><li  class=""><a >Control Panel Javascript</a><ul><li  class=""><a href="../development/control-panel-js/events.html">Custom jQuery Events</a></li><li  class=""><a href="../development/control-panel-js/table.html">Table Plugin</a></li><li  class=""><a href="../development/control-panel-js/rich-text-editor.html">Rich Text Editor</a></li><li  class=""><a href="../development/control-panel-js/rangesandselections.html">Ranges and Selections</a></li><li  class=""><a href="../development/control-panel-js/wysihat-api.html">WysiHat API</a></li></ul></li><li  class=""><a href="../development/constants.html">Constants Reference</a></li><li  class=""><a href="../development/json-version-feed.html">JSON Version Feed</a></li><li  class=""><a >Legacy Reference</a><ul><li  class=""><a href="../development/legacy/common-functions.html">Common Functions</a></li><li  class=""><a href="../development/legacy/controllers.html">Controllers</a></li><li  class=""><a href="../development/legacy/drivers.html">Drivers</a></li><li  class=""><a href="../development/legacy/libraries/index.html">Libraries</a><ul><li  class=""><a href="../development/legacy/libraries/creating-libraries.html">Creating Libraries</a></li><li  class=""><a href="../development/legacy/libraries/benchmark.html">Benchmarking Class</a></li><li  class=""><a href="../development/legacy/libraries/cache.html">Cache Class</a></li><li  class=""><a href="../development/legacy/libraries/config.html">Config Class</a></li><li  class=""><a href="../development/legacy/libraries/cp.html">CP Class</a></li><li  class=""><a href="../development/legacy/libraries/database.html">Database Class</a></li><li  class=""><a href="../development/legacy/libraries/email.html">Email Class</a></li><li  class=""><a href="../development/legacy/libraries/file-uploading.html">File Uploading Class</a></li><li  class=""><a href="../development/legacy/libraries/form-validation.html">Form Validation Class</a></li><li  class=""><a href="../development/legacy/libraries/functions.html">Functions Class</a></li><li  class=""><a href="../development/legacy/libraries/image-lib.html">Image Manipulation Class</a></li><li  class=""><a href="../development/legacy/libraries/input.html">Input Class</a></li><li  class=""><a href="../development/legacy/libraries/javascript.html">Javascript Class</a></li><li  class=""><a href="../development/legacy/libraries/language.html">Language Class</a></li><li  class=""><a href="../development/legacy/libraries/layout.html">Layout Class</a></li><li  class=""><a href="../development/legacy/libraries/loader.html">Loader Class</a></li><li  class=""><a href="../development/legacy/libraries/localization.html">Localize Class</a></li><li  class=""><a href="../development/legacy/libraries/logger.html">Logger Class</a></li><li  class=""><a href="../development/legacy/libraries/mime-type.html">Mime Type Class</a></li><li  class=""><a href="../development/legacy/libraries/output.html">Output Class</a></li><li  class=""><a href="../development/legacy/libraries/pagination.html">Pagination Class</a></li><li  class=""><a href="../development/legacy/libraries/rss-parser.html">RSS Parser Class</a></li><li  class=""><a href="../development/legacy/libraries/security.html">Security Class</a></li><li  class=""><a href="../development/legacy/libraries/session.html">Session Class</a></li><li  class=""><a href="../development/legacy/libraries/table.html">Table Class</a></li><li  class=""><a href="../development/legacy/libraries/template.html">Template Class</a></li><li  class=""><a href="../development/legacy/libraries/typography.html">Typography Class</a></li><li  class=""><a href="../development/legacy/libraries/uri.html">URI Class</a></li><li  class=""><a href="../development/legacy/libraries/xmlparser.html">XML Parser Class</a></li></ul></li><li  class=""><a href="../development/legacy/database/index.html">Database Driver</a><ul><li  class=""><a href="../development/legacy/database/active-record.html">Active Record</a></li><li  class=""><a href="../development/legacy/database/results.html">Query Results</a></li><li  class=""><a href="../development/legacy/database/raw.html">Raw Queries and Metadata</a></li><li  class=""><a href="../development/legacy/database/utilities.html">Database Utility Class</a></li><li  class=""><a href="../development/legacy/database/forge.html">Database Forge Class</a></li><li  class=""><a href="../development/legacy/database/connecting-to-an-external-database.html">Connecting to an External Database</a></li></ul></li><li  class=""><a href="../development/legacy/helpers/index.html">Helpers</a><ul><li  class=""><a href="../development/legacy/helpers/array-helper.html">Array Helper</a></li><li  class=""><a href="../development/legacy/helpers/cookie-helper.html">Cookie Helper</a></li><li  class=""><a href="../development/legacy/helpers/directory-helper.html">Directory Helper</a></li><li  class=""><a href="../development/legacy/helpers/download-helper.html">Download Helper</a></li><li  class=""><a href="../development/legacy/helpers/file-helper.html">File Helper</a></li><li  class=""><a href="../development/legacy/helpers/form-helper.html">Form Helper</a></li><li  class=""><a href="../development/legacy/helpers/html-helper.html">HTML Helper</a></li><li  class=""><a href="../development/legacy/helpers/language-helper.html">Language Helper</a></li><li  class=""><a href="../development/legacy/helpers/number-helper.html">Number Helper</a></li><li  class=""><a href="../development/legacy/helpers/path-helper.html">Path Helper</a></li><li  class=""><a href="../development/legacy/helpers/security-helper.html">Security Helper</a></li><li  class=""><a href="../development/legacy/helpers/string-helper.html">String Helper</a></li><li  class=""><a href="../development/legacy/helpers/text-helper.html">Text Helper</a></li><li  class=""><a href="../development/legacy/helpers/url-helper.html">URL Helper</a></li><li  class=""><a href="../development/legacy/helpers/xml-helper.html">XML Helper</a></li></ul></li><li  class=""><a href="../development/legacy/api/index.html">Legacy API Library</a><ul><li  class=""><a href="../development/legacy/api/api-channel-categories.html">Channel Categories API</a></li><li  class=""><a href="../development/legacy/api/api-channel-fields.html">Channel Fields API</a></li><li  class=""><a href="../development/legacy/api/api-channel-structure.html">Channel Structure API</a></li><li  class=""><a href="../development/legacy/api/api-template-structure.html">Template Structure API</a></li></ul></li></ul></li><li  class=""><a >Guidelines</a><ul><li  class=""><a href="../development/guidelines/index.html">Overview</a></li><li  class=""><a href="../development/guidelines/checklist.html">Guidelines Checklist</a></li><li  class=""><a href="../development/guidelines/general.html">General Style and Syntax</a></li><li  class=""><a href="../development/guidelines/in-app-documentation.html">In-app Documentation</a></li><li  class=""><a href="../development/guidelines/performance.html">Performance Guidelines</a></li><li  class=""><a href="../development/guidelines/security.html">Security Guidelines</a></li><li  class=""><a href="../development/guidelines/view-php-syntax.html">View Files and PHP Syntax</a></li></ul></li><li  class=""><a href="../development/v4-addon-migration.html">v4 Add-on Migration</a></li><li  class=""><a href="../development/v3-add-on-migration.html">v3 Add-on Migration</a></li></ul></li><li  class=""><a href="../bugs-and-security-reports.html">Bugs and Security Reports</a></li><li  class=""><a href="../style-guide.html">Docs Style Guide</a></li></ul>
				</div>
			</div>
		</div>

		<section class="docs-content-wrapper">
			<div class="content" id="docsearch-content">
				<!--
    This source file is part of the open source project
    ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide)

    @link      https://expressionengine.com/
    @copyright Copyright (c) 2003-2020, Packet Tide, LLC (https://www.packettide.com)
    @license   https://expressionengine.com/license Licensed under Apache License, Version 2.0
-->


		<h1>
		<span class="anchor" id="pagination"></span>
		<a href="#pagination">Pagination</a>
		</h1><div class="table-of-contents"><ul>
<li><a href="#example-code">Example Code</a></li>
<li><a href="#parameters">Parameters</a></li>
<li><a href="#variable-pairs">Variable Pairs</a></li>
<li><a href="#variables-1">Variables</a></li>
</ul>
</div><p>Pagination works identically across all first-party modules and allows you to display a limited number of entries and then automatically link to the next set. That way you can, for example, show comments 1-10 on the first page and automatically link to pages that display 11-20, 21-30, etc.</p><p>You have two choices as to the style of the navigation element. The first method would look something like this:</p><pre><code>Page 27 of 344 pages  « First  <span class="hljs-tag">&lt;  <span class="hljs-attr">11</span> <span class="hljs-attr">12</span> <span class="hljs-attr">13</span> <span class="hljs-attr">14</span> <span class="hljs-attr">15</span> &gt;</span>  Last »</code></pre><p>The second method is a more traditional “next page” / “previous page” output:</p><pre><code>Previous Page | Next Page</code></pre><p>Pagination will also automatically restrict itself to any category you’re currently viewing. So if you have a category specified in your channel entries tag or you are viewing the entries of a category, then the pagination links will automatically restrict themselves to only entries in that category.</p>
		<h2>
		<span class="anchor" id="example-code"></span>
		<a href="#example-code">Example Code</a>
		</h2><p>Here are two basic code examples, one for each of the methods mentioned above. Information about the variables and parameters are covered later.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">exp:channel:entries</span> <span class="hljs-attr">channel</span>=<span class="hljs-string">"news"</span> <span class="hljs-attr">orderby</span>=<span class="hljs-string">"date"</span> <span class="hljs-attr">sort</span>=<span class="hljs-string">"desc"</span> <span class="hljs-attr">limit</span>=<span class="hljs-string">"1"</span> <span class="hljs-attr">paginate</span>=<span class="hljs-string">"bottom"</span>}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span></span><span class="hljs-template-tag">{<span class="hljs-name">title</span>}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    </span><span class="hljs-template-tag">{<span class="hljs-name">summary</span>}</span><span class="xml">
    </span><span class="hljs-template-tag">{<span class="hljs-name">body</span>}</span><span class="xml">

    </span><span class="hljs-template-tag">{<span class="hljs-name">paginate</span>}</span><span class="xml">
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Page </span><span class="hljs-template-tag">{<span class="hljs-name">current_page</span>}</span><span class="xml"> of </span><span class="hljs-template-tag">{<span class="hljs-name">total_pages</span>}</span><span class="xml"> pages </span><span class="hljs-template-tag">{<span class="hljs-name">pagination_links</span>}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    </span><span class="hljs-template-tag">{/<span class="hljs-name">paginate</span>}</span><span class="xml">
</span><span class="hljs-template-tag">{/<span class="hljs-name">exp:channel:entries</span>}</span><span class="xml"></span></code></pre><p class="alert alert--warn"> <strong>Note:</strong> It does <strong>not</strong> matter where you put your <code>{paginate}</code> code within the channel entries tag. The HTML markup within the <code>{paginate}</code> tag pair will be placed in the appropriate location according to what you specify with the <code>paginate=</code> parameter (detailed below).</p><p>And for the “next/previous” method:</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">exp:comment:entries</span> <span class="hljs-attr">channel</span>=<span class="hljs-string">"news"</span> <span class="hljs-attr">sort</span>=<span class="hljs-string">"desc"</span> <span class="hljs-attr">limit</span>=<span class="hljs-string">"1"</span> <span class="hljs-attr">paginate</span>=<span class="hljs-string">"bottom"</span>}</span><span class="xml">
    </span><span class="hljs-template-tag">{<span class="hljs-name">comment</span>}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>By </span><span class="hljs-template-tag">{<span class="hljs-name">name</span>}</span><span class="xml"> on </span><span class="hljs-template-tag">{<span class="hljs-name">comment_date</span> <span class="hljs-attr">format</span>=<span class="hljs-string">"%Y %m %d"</span>}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

    </span><span class="hljs-template-tag">{<span class="hljs-name">paginate</span>}</span><span class="xml">
        </span><span class="hljs-template-tag">{<span class="hljs-name"><span class="hljs-keyword">if</span></span> previous_page}</span><span class="xml">
            <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">auto_path</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>Previous Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> &amp;nbsp;
        </span><span class="hljs-template-tag">{/<span class="hljs-name"><span class="hljs-keyword">if</span></span>}</span><span class="xml">
        </span><span class="hljs-template-tag">{<span class="hljs-name"><span class="hljs-keyword">if</span></span> next_page}</span><span class="xml">
            <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">auto_path</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span>Next Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
        </span><span class="hljs-template-tag">{/<span class="hljs-name"><span class="hljs-keyword">if</span></span>}</span><span class="xml">
    </span><span class="hljs-template-tag">{/<span class="hljs-name">paginate</span>}</span><span class="xml">
</span><span class="hljs-template-tag">{/<span class="hljs-name">exp:comment:entries</span>}</span><span class="xml"></span></code></pre><p class="alert alert--warn"> <strong>Note:</strong> You can have multiple <code>{paginate}</code> blocks with different content, but you’ll need to use <code>paginate=inline</code>.</p>
		<h2>
		<span class="anchor" id="parameters"></span>
		<a href="#parameters">Parameters</a>
		</h2><p>Pagination tag pair parameters should be used in the enclosing tag. For example:</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">exp:comment:entries</span> <span class="hljs-attr">limit</span>=<span class="hljs-string">"1"</span> <span class="hljs-attr">paginate</span>=<span class="hljs-string">"bottom"</span>}</span><span class="xml"></span></code></pre>
		<h3>
		<span class="anchor" id="paginate"></span>
		<a href="#paginate">paginate=</a>
		</h3><p>This parameter determines where the pagination code will appear:</p><pre><code>paginate=<span class="hljs-string">"top"</span> paginate=<span class="hljs-string">"bottom"</span>  paginate=<span class="hljs-string">"both"</span>  paginate=<span class="hljs-string">"inline"</span>  paginate=<span class="hljs-string">"hidden"</span></code></pre><ol>
<li><code>top</code>: The navigation text and links will appear <em>above</em> your list of entries.</li>
<li><code>bottom</code>: The navigation text and links will appear <em>below</em> your list of entries.</li>
<li><code>both</code>: The navigation text and links will appear both above and below your list of entries.</li>
<li><code>inline</code>: The navigation text and links will appear within the list of entries for each entry.</li>
<li><code>hidden</code>: The navigation text and links will <strong>not</strong> appear, but your entries will be paginated. (This is useful for things like JSON.)</li>
</ol>
<p>If no parameter is specified, the navigation block will default to the “bottom” behavior.</p>
		<h3>
		<span class="anchor" id="paginate_base"></span>
		<a href="#paginate_base">paginate_base=</a>
		</h3><pre><code>paginate_base=<span class="hljs-string">"site/index"</span></code></pre><p>This tells ExpressionEngine to override the normal pagination link locations and point instead to the explicitly stated template group and template.</p>
		<h2>
		<span class="anchor" id="variable-pairs"></span>
		<a href="#variable-pairs">Variable Pairs</a>
		</h2>
		<h3>
		<span class="anchor" id="paginate-1"></span>
		<a href="#paginate-1">paginate</a>
		</h3><p>The opening and closing tags for pagination. This can to be used in conjunction with the <a href="#paginate">paginate=</a> parameter to determine where the contents of this tag will appear. See below for the available variables for use inside this tag. This tag is wrapped around either the single variables (see below) or the next/previous variable pairs.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">paginate</span>}</span><span class="xml">  </span><span class="hljs-template-tag">{/<span class="hljs-name">paginate</span>}</span><span class="xml"></span></code></pre>
		<h3>
		<span class="anchor" id="pagination_links"></span>
		<a href="#pagination_links">pagination_links</a>
		</h3><p>This variable shows the current page you are on as well as “surrounding” pages in addition to links for next/previous pages and first/last pages.</p><p>You can use <code>{pagination_links}</code> in two ways. It can be used as a single variable:</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">paginate</span>}</span><span class="xml">
  </span><span class="hljs-template-tag">{<span class="hljs-name">pagination_links</span>}</span><span class="xml">
</span><span class="hljs-template-tag">{/<span class="hljs-name">paginate</span>}</span><span class="xml"></span></code></pre><p>And the output looks like this:</p><pre><code>« First  <span class="hljs-tag">&lt;  <span class="hljs-attr">11</span> <span class="hljs-attr">12</span> <span class="hljs-attr">13</span> <span class="hljs-attr">14</span> <span class="hljs-attr">15</span> &gt;</span>  Last »</code></pre><p>When used as a pair, you have a lot more flexibility with the markup:</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">paginate</span>}</span><span class="xml">
  </span><span class="hljs-template-tag">{<span class="hljs-name">pagination_links</span>}</span><span class="xml">
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
      </span><span class="hljs-template-tag">{<span class="hljs-name">first_page</span>}</span><span class="xml">
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-first"</span>&gt;</span>First Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      </span><span class="hljs-template-tag">{/<span class="hljs-name">first_page</span>}</span><span class="xml">

      </span><span class="hljs-template-tag">{<span class="hljs-name">previous_page</span>}</span><span class="xml">
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-previous"</span>&gt;</span>Previous Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      </span><span class="hljs-template-tag">{/<span class="hljs-name">previous_page</span>}</span><span class="xml">

      </span><span class="hljs-template-tag">{<span class="hljs-name">page</span>}</span><span class="xml">
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_page_number</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string"> </span></span></span><span class="hljs-template-tag">{<span class="hljs-name"><span class="hljs-keyword">if</span></span> current_page}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">active</span></span></span><span class="hljs-template-tag">{/<span class="hljs-name"><span class="hljs-keyword">if</span></span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_page_number</span>}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      </span><span class="hljs-template-tag">{/<span class="hljs-name">page</span>}</span><span class="xml">

      </span><span class="hljs-template-tag">{<span class="hljs-name">next_page</span>}</span><span class="xml">
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-next"</span>&gt;</span>Next Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      </span><span class="hljs-template-tag">{/<span class="hljs-name">next_page</span>}</span><span class="xml">

      </span><span class="hljs-template-tag">{<span class="hljs-name">last_page</span>}</span><span class="xml">
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-last"</span>&gt;</span>Last Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      </span><span class="hljs-template-tag">{/<span class="hljs-name">last_page</span>}</span><span class="xml">
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
  </span><span class="hljs-template-tag">{/<span class="hljs-name">pagination_links</span>}</span><span class="xml">
</span><span class="hljs-template-tag">{/<span class="hljs-name">paginate</span>}</span><span class="xml"></span></code></pre><p>There are one parameter, two variables, five variable pairs, and one conditional variable available when using the {pagination_links} pair.</p>
		<h4>
		<span class="anchor" id="parameters-1"></span>
		<a href="#parameters-1">Parameters</a>
		</h4>
		<h5>
		<span class="anchor" id="page_padding"></span>
		<a href="#page_padding">page_padding</a>
		</h5><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_links</span> <span class="hljs-attr">page_padding</span>=<span class="hljs-string">"2"</span>}</span><span class="xml"></span></code></pre><p><code>page_padding</code> defaults to 2 if left unset. <code>page_padding</code> will allow you to determine how many pages are shown on either side of the current page.</p><p class="alert alert--warn"> <strong>Note:</strong> If you’re paginating over 10 items and showing 1 item per page, if you’re on the first page, you’d normally see this:</p><pre><code>*1*  2  3  Next Page  Last Page</code></pre><p>If you changed <code>page_padding</code> to another value, say 5, you’d see more page numbers:</p><pre><code>*1*  2  3  4  5  6  Next Page  Last Page</code></pre><p>If you later changed to page 4, you’d see this:</p><pre><code>Previous Page  1  2  3  *4*  5  6  7  8  9  Next Page  Last Page</code></pre>
		<h5>
		<span class="anchor" id="always_show_first_last"></span>
		<a href="#always_show_first_last">always_show_first_last</a>
		</h5><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_links</span> <span class="hljs-attr">always_show_first_last</span>=<span class="hljs-string">"yes"</span>}</span><span class="xml"></span></code></pre><p>Set this parameter to <code>yes</code> if you always want to see the links for the first and last pages.</p><p class="alert alert--warn"> <strong>Note:</strong> If left unset or set to <code>no</code>, first and last links will only be shown if the first and/or last page’s number isn’t shown.</p><p>For example, if you have 5 pages and <code>pagination_links</code> is set at 2 and you’re currently on the 3rd page you won’t see a first or last page link because all five pages are shown:</p><pre><code>Previous Page  1  2  *3*  4  5  Next Page</code></pre><p>If you changed <code>pagination_links</code> to 1, then you’d see both first and last links because the page numbers <strong>are not</strong> shown:</p><pre><code>First Page  Previous Page  2  *3*  4  Next Page  Last Page</code></pre>
		<h4>
		<span class="anchor" id="variables"></span>
		<a href="#variables">Variables</a>
		</h4>
		<h5>
		<span class="anchor" id="pagination_page_number"></span>
		<a href="#pagination_page_number">pagination_page_number</a>
		</h5><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_page_number</span>}</span><span class="xml"></span></code></pre><p>Outputs the page number associated with the current page in the {pagination_links} tag pair.</p>
		<h5>
		<span class="anchor" id="pagination_url"></span>
		<a href="#pagination_url">pagination_url</a>
		</h5><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"></span></code></pre><p>Outputs the URL associated with the current page in the {pagination_links} tag pair.</p>
		<h4>
		<span class="anchor" id="variable-pairs-1"></span>
		<a href="#variable-pairs-1">Variable Pairs</a>
		</h4><p>These four variable pairs can be used to display specific pages within the pagination:</p><p class="alert alert--warn"> <strong>Note:</strong> The markup within the <code>first_page</code> and <code>last_page</code> variable pairs will only display when there are at least 4 pages of content.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">first_page</span>}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-first"</span>&gt;</span>First Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</span><span class="hljs-template-tag">{/<span class="hljs-name">first_page</span>}</span><span class="xml">

</span><span class="hljs-template-tag">{<span class="hljs-name">previous_page</span>}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-previous"</span>&gt;</span>Previous Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</span><span class="hljs-template-tag">{/<span class="hljs-name">previous_page</span>}</span><span class="xml">

</span><span class="hljs-template-tag">{<span class="hljs-name">next_page</span>}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-next"</span>&gt;</span>Next Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</span><span class="hljs-template-tag">{/<span class="hljs-name">next_page</span>}</span><span class="xml">

</span><span class="hljs-template-tag">{<span class="hljs-name">last_page</span>}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-last"</span>&gt;</span>Last Page<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</span><span class="hljs-template-tag">{/<span class="hljs-name">last_page</span>}</span><span class="xml"></span></code></pre><p>The <code>{page}</code> variable pair can be used to display standard pagination links:</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">page</span>}</span><span class="xml">
  <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_url</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"page-</span></span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_page_number</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>&gt;</span></span><span class="hljs-template-tag">{<span class="hljs-name">pagination_page_number</span>}</span><span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</span><span class="hljs-template-tag">{/<span class="hljs-name">page</span>}</span><span class="xml"></span></code></pre>
		<h4>
		<span class="anchor" id="conditional-variables"></span>
		<a href="#conditional-variables">Conditional Variables</a>
		</h4><p>Check and see if the current {page} link is the current page.</p><pre><code>{<span class="hljs-keyword">if</span> current_page}<span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"current"</span>{/<span class="hljs-keyword">if</span>}</code></pre>
		<h3>
		<span class="anchor" id="if-next_page"></span>
		<a href="#if-next_page">if next_page</a>
		</h3><p>This tag will conditionally display the code inside the tag if there is a “next” page. If there is no next page then the content simply will not be displayed.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name"><span class="hljs-keyword">if</span></span> next_page}</span><span class="xml">  </span><span class="hljs-template-tag">{/<span class="hljs-name"><span class="hljs-keyword">if</span></span>}</span><span class="xml"></span></code></pre>
		<h3>
		<span class="anchor" id="if-previous_page"></span>
		<a href="#if-previous_page">if previous_page</a>
		</h3><p>This tag will conditionally display the code inside the tag if there is a “previous” page. If there is no previous page then the content simply will not be displayed.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name"><span class="hljs-keyword">if</span></span> previous_page}</span><span class="xml">  </span><span class="hljs-template-tag">{/<span class="hljs-name"><span class="hljs-keyword">if</span></span>}</span><span class="xml"></span></code></pre>
		<h2>
		<span class="anchor" id="variables-1"></span>
		<a href="#variables-1">Variables</a>
		</h2><p>These individual variables are for use inside the <a href="#paginate-1">{paginate}</a> tag pair.</p>
		<h3>
		<span class="anchor" id="auto_path"></span>
		<a href="#auto_path">auto_path</a>
		</h3><p>The {auto_path} variable is used inside of the <a href="#if-next_page">{if next_page}</a> and <a href="#if-previous_page">{if previous_page}</a> variable pairs. It is dynamically replaced with the correct path to the next/previous page. Unlike other “path” variables, this variable does <strong>not</strong> require the Template_Group/Template to be specified.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">auto_path</span>}</span><span class="xml"></span></code></pre>
		<h3>
		<span class="anchor" id="current_page"></span>
		<a href="#current_page">current_page</a>
		</h3><p>This variable is replaced by the page number of the current page you are viewing.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">current_page</span>}</span><span class="xml"></span></code></pre>
		<h3>
		<span class="anchor" id="total_pages"></span>
		<a href="#total_pages">total_pages</a>
		</h3><p>The total number of pages you have.</p><pre><code><span class="xml"></span><span class="hljs-template-tag">{<span class="hljs-name">total_pages</span>}</span><span class="xml"></span></code></pre>

				<hr>

				<p class="docs-footer">
					<span>ExpressionEngine 5.4.2 Docs
					<br>
					<span class="copyright"><a href="https://packettide.com/">©2002–2021 Packet Tide,LLC.</a></span>
					</span>
					<a target="_blank" class="docs-contribute-to-page-button" href="https://github.com/ExpressionEngine/ExpressionEngine-User-Guide/blob/stability/docs/templates/pagination.md">Edit this page</a>
				</p>
			</div>
		</section>

		<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
		<script type="text/javascript">
			docsearch({
				apiKey: 'ba20cc61ab2d8a0148041c98eeddd9c6',
				indexName: 'expressionengine',
				inputSelector: '#docsearch-input',
				algoliaOptions: { 'facetFilters': ["version:v5"] },
				debug: false
			});
		</script>

		<script src="../_assets/main.min.js"></script>
	</body>
</html>



