Make WordPress Core

Opened 7 years ago

Last modified 14 months ago

#49958 new enhancement

Improve paginator in general-template.php

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

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
7 years ago

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

#2 @sabernhardt
14 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.


14 months ago

#4 @SirLouen
14 months ago

  • Component Posts, Post Types → 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.