Wordpress Bundle
  • What is Wordpress Bundle?
  • Getting started
    • Installation
    • Wordpress
    • Router
    • Cron job
    • Templates
  • Reference
    • Argument resolver
    • Controller
      • AdminAction
      • BlogController
      • FrontAction
      • WordpressAction
    • Entity
      • Block
      • Blog
      • Comment
      • File
      • Image
      • Menu
      • MenuItem
      • Post
      • Term
      • User
    • Repository
      • CommentRepository
      • PostRepository
      • TermRepository
      • UserRepository
    • Service
      • PaginationService
      • BreacrumbService
  • Guides
    • Server requirements
    • Install plugins
    • Use Multisite
    • Gutenberg
    • WP Steroids plugin
      • Image options
      • Maintenance
      • Admin pages removal
      • WYSIWYG Editor
      • Feature Support
      • Multi-site configuration
      • Constants definition
      • ACF configuration
      • Menu
      • Custom Post type
      • Advanced permalink settings
      • Custom Taxonomy
      • Templates
      • Page states
      • External table viewer
      • Roles
      • Optimisations
      • Security
      • Search
    • Twig Cookbook
    • Inject variables in all templates
    • Internationalization
    • Extending Wordpress Bundle
    • Error pages
    • Site health
  • Integrations
    • Advanced Custom Fields
      • Install ACF PRO
  • Extras
    • Migrating from 1.x to 2.0
    • Roadmap
    • Changelog
    • Alternatives
Powered by GitBook
On this page
  • Methods
  • Exemple

Was this helpful?

  1. Reference
  2. Service

PaginationService

Retrieve paginated links for archive post page

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

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

View

{% 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 %}
PreviousServiceNextBreacrumbService

Last updated 3 years ago

Was this helpful?