Skip to main content
deleted 145 characters in body
Source Link
NevNein
  • 111
  • 5

After finding myself in this same situation, I decided to gave a detailed answer in case anyone stumbles here:

This is not documented, but digging through the source code and looking at old commits of the documentation itself I found that you can manually generate the pagination for a page with

Timber::get_pagination()

which is a wrapper for

Timber\Pagination::get_pagination()

Skimming through the source of the Pagination class you can see how Timber builds it behind the scenes. The main takeaways are that you can pass the same arguments used by paginate_links or a single integer as the overall "size" argument (for the total number of pages that get shown), as also stated in this issue.

So to answer the question, you can build your custom pagination passing the size parameter (or an array for finer control), store it in the context and use it as usual in the templates

$context['custom_pagination'] = Timber::get_pagination(5);

Or even override the default if you don't want to change your templates

$context['posts']['pagination'] = Timber::get_pagination(5);

After finding myself in this same situation, I decided to gave a detailed answer in case anyone stumbles here:

This is not documented, but digging through the source code and looking at old commits of the documentation itself I found that you can manually generate the pagination for a page with

Timber::get_pagination()

which is a wrapper for

Timber\Pagination::get_pagination()

Skimming through the source of the Pagination class you can see how Timber builds it behind the scenes. The main takeaways are that you can pass the same arguments used by paginate_links or a single integer as the overall "size" argument (for the total number of pages that get shown), as also stated in this issue.

So to answer the question, you can build your custom pagination passing the size parameter (or an array for finer control), store it in the context and use it as usual in the templates

$context['custom_pagination'] = Timber::get_pagination(5);

Or even override the default if you don't want to change your templates

$context['posts']['pagination'] = Timber::get_pagination(5);

After finding myself in this same situation, I decided to gave a detailed answer in case anyone stumbles here:

This is not documented, but digging through the source code and looking at old commits of the documentation itself I found that you can manually generate the pagination for a page with

Timber::get_pagination()

which is a wrapper for

Timber\Pagination::get_pagination()

Skimming through the source of the Pagination class you can see how Timber builds it behind the scenes. The main takeaways are that you can pass the same arguments used by paginate_links or a single integer as the overall "size" argument (for the total number of pages that get shown), as also stated in this issue.

So to answer the question, you can build your custom pagination passing the size parameter (or an array for finer control), store it in the context and use it as usual in the templates

$context['custom_pagination'] = Timber::get_pagination(5);
Source Link
NevNein
  • 111
  • 5

After finding myself in this same situation, I decided to gave a detailed answer in case anyone stumbles here:

This is not documented, but digging through the source code and looking at old commits of the documentation itself I found that you can manually generate the pagination for a page with

Timber::get_pagination()

which is a wrapper for

Timber\Pagination::get_pagination()

Skimming through the source of the Pagination class you can see how Timber builds it behind the scenes. The main takeaways are that you can pass the same arguments used by paginate_links or a single integer as the overall "size" argument (for the total number of pages that get shown), as also stated in this issue.

So to answer the question, you can build your custom pagination passing the size parameter (or an array for finer control), store it in the context and use it as usual in the templates

$context['custom_pagination'] = Timber::get_pagination(5);

Or even override the default if you don't want to change your templates

$context['posts']['pagination'] = Timber::get_pagination(5);