> For the complete documentation index, see [llms.txt](https://metabolism.gitbook.io/symfony-wordpress-bundle/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://metabolism.gitbook.io/symfony-wordpress-bundle/reference/service/paginationservice.md).

# PaginationService

## Methods

#### build($args)

| Proprety             | Default                        |
| -------------------- | ------------------------------ |
| base                 | `get_pagenum_link()`           |
| format               | `$wp_rewrite->pagination_base` |
| total                | `$wp_query->max_num_pages`     |
| current              | `get_query_var( 'paged' )`     |
| show\_all            | `false`                        |
| prev\_text           | `__( 'Previous' )`             |
| next\_text           | `__( 'Next' )`                 |
| end\_size            | `1`                            |
| mid\_size            | `2`                            |
| add\_args            | `[]`                           |
| add\_fragment        | `""`                           |
| before\_page\_number | `""`                           |
| after\_page\_number  | `""`                           |

## Exemple

Controller

```php
public function categoryAction(Term $term, array $posts, PaginationService $paginationService)
{
  return $this->render('archive.html.twig', [
    'pagination'=>$paginationService->build(),
     'posts'=>$posts,
     'term'=>$term
  ]);
}
```

View

```liquid
{% if pagination %}
    <nav class="navigation pagination" role="navigation">
        <h2 class="screen-reader-text">Posts navigation</h2>
        <div class="nav-links">
            {% if pagination.prev|default() %}
                <a class="prev page-numbers"  href="{{ pagination.prev.link }}">
                    <span class="nav-prev-text">{{ pagination.prev.text }}</span>
                </a>
            {% endif %}
            {% for page in pagination.pages %}
                <a class="page-numbers" {% if not page.current %}href="{{ page.link }}"{% endif %}>{{ page.text }}</a>
            {% endfor %}
            {% if pagination.next|default() %}
                <a class="next page-numbers" href="{{ pagination.next.link }}">
                    <span class="nav-next-text">{{ pagination.next.text }}</span>
                </a>
            {% endif %}
        </div>
    </nav>
{% endif %}
```
