Skip to content
Klemens Starybrat edited this page Apr 22, 2021 · 9 revisions

Pagination

To use pagination, you need to set the following parameters in the shortcode:

  • pagination set it to yes. [catlist pagination=yes]

  • numberposts - Posts per page are set with the numberposts parameter. [catlist pagination=yes numberposts=5]

  • instance (only necessary when using the shortcode with pagination more than once in the same page/post) - a number or name to identify the instance where you are using pagination. Since you can use the shortcode several times in the same page or post, you need to identify the instance so that you paginate only that instance.

Example:

[catlist id=3 numberposts=5 pagination=yes instance=1]

[catlist id=5 numberposts=15 pagination=yes instance=2]

AJAX pagination

Use the LCP Ajax Pagination add-on plugin.

Bookmarks in pagination links

Pagination links are automatically appended with bookmarks to the list they are part of, i.e. lcp_instance. While this is desirable by many users, it can cause a real mess in many (badly written 😉 ) themes and plugins. So @klemens-st proposed the pagination_bookmarks shortcode parameter. If present and set to no the plugin won't append bookmarks to pagination URLs.

Default example link http://example.org?lcp_page0=2#lcp_instance_0

With pagination_bookmarks=no http://example.org?lcp_page0=2

Next and Previous buttons

You can customize what to show for the "next" and "previous" buttons in the pagination navigation. Use the following params:

  • pagination_prev - Replace the "<<" characters in the "previous" button in the pagination navigation with a custom text.
  • pagination_next - Replace the ">>" characters in the "next" button in the pagination navigation with a custom text.

Default Options

You can also set a default value for pagination in the Options Page. This will apply every time you use the shortcode. You can override the option by using pagination='yes' and pagination='no' in the shortcode. Note: for full backward compatibility pagination='true' and pagination='false' work as well.

Pagination padding

You can customize how many pages to show in the pagination with the pagination_padding parameter. When using [catlist pagination=yes], we get a pagination like this:

1 2 3 4 5 6 ... 40 >>

If we go to page 12, we see 5 more pages to each side:

<< 1 ... 7 8 9 10 11 12 13 14 15 16 17 ... 40 >>

With pagination_padding, we can customize the amount of pages for each side. So [catlist pagination=yes pagination_padding=2] will show this:

<< 1 ... 10 11 12 13 14 ... 40 >>

Changing the pagination CSS

If you want to customize the way the pagination is displayed, you can copy the lcp_paginator.css file from the plugin's directory to your theme's directory and customize it. Do not customize the file on the plugin's directory since this file will be overwritten every time you update the plugin.

The current page in pagination has its own CSS class:

<li class='lcp_currentpage'>current_page</li>

"Previous" and "next" links in pagination navigation have their own classes too:

<a href="[next page URL]" class='lcp_nextlink'>>></a>

<a href="[previous page URL]" class='lcp_prevlink'><<</a>

So you can style the current page number and "next"/"previous" buttons differently if you want to.