Make WordPress Core

Opened 6 years ago

Last modified 3 months ago

#49958 new enhancement

Improve paginator in general-template.php

Reported by: lolitsjohnnyboy's profile lolitsjohnnyboy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: reporter-feedback
Focuses: template Cc:

Description (last modified by SergeyBiryukov)

I would like to add custom classes to the default paginator in the general-template.php file. For that I would suggest the following change:

<?php
$page_links[] = sprintf(
        '<a class="page-numbers %s" href="%s">%s</a>',
        /** This filter is documented in wp-includes/general-template.php */
        esc_attr( apply_filters( 'paginate_classes' ) ),
        esc_url( apply_filters( 'paginate_links', $link ) ),
        $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number']
);

That needs to be applied to every page-numbers element and would be very helpful.

Change History (4)

#1 @SergeyBiryukov
6 years ago

  • Component changed from General to Posts, Post Types
  • Description modified (diff)
  • Focuses template added; ui removed

#2 @sabernhardt
3 months ago

#35696 suggests adding classes to multiple elements in the same hook.

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


3 months ago

#4 @SirLouen
3 months ago

  • Component changed from Posts, Post Types to Themes
  • Keywords reporter-feedback added

@lolitsjohnnyboy looks good, but we need more info, explain how it will be used. This could be technically applied to a dozen of classes and its not a common practice in the WP code to filter classes (after all we have other classes to target if needed). According to @sabernhardt related ticket #35696 there seems to be an alternative option that could fit better.

So I will leave this to be evaluated, ideally both tickets at the same time and leave just one for a conclusion.

Note: See TracTickets for help on using tickets.