Make WordPress Core

Opened 12 years ago

Last modified 6 years ago

#24705 new enhancement

wp_link_pages() does not showing active current element

Reported by: alexufo's profile Alexufo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 2.2
Component: Posts, Post Types Keywords: dev-feedback has-patch
Focuses: template Cc:

Description

By full analogy of all wp functions, wp_link_pages must generate active class element too.

1
<a href="/2">2</a>
<a href="/3">3</a>
<a href="/4">4</a>

but should be

<span class="current">1</span>
<a href="/2">2</a>
<a href="/3">3</a>
<a href="/4">4</a>

Attachments (5)

24075#.patch (607 bytes) - added by anonymized_10276468 12 years ago.
24705#.patch (607 bytes) - added by anonymized_10276468 12 years ago.
patched up awaiting review
24705.2.patch (596 bytes) - added by Frank Klein 11 years ago.
post-template.php.wp_link_pages.patch (687 bytes) - added by chipbennett 11 years ago.
Alternate patch. Uses if/else rather than if/elseif, and more current-page-link as CSS class
post-template.diff (943 bytes) - added by danielpataki 11 years ago.
Alternate Patch For Issue - different class name

Download all attachments as: .zip

Change History (16)

#1 @Alexufo
12 years ago

  • Type changed from defect (bug) to enhancement

#2 @Alexufo
12 years ago

  • Summary changed from wp_link_pages() as not shown active element to wp_link_pages() does not showing active element

#3 @anonymized_10276468
12 years ago

  • Cc anand.potukuchi added
  • Keywords has-patch added; needs-patch removed

Keywords' changed from needs_patch to has_patch

Last edited 12 years ago by anonymized_10276468 (previous) (diff)

#4 @anonymized_10276468
12 years ago

  • Keywords dev-feedback added

#5 @SergeyBiryukov
12 years ago

  • Component changed from General to Template

@anonymized_10276468
12 years ago

patched up awaiting review

#6 @Frank Klein
11 years ago

  • Cc contact@… added

I updated the previous patch to only add the current class to the currently active page element.

Adding this to the function might seem like a tiny improvement, but it actually helps a lot if you want to style the active page element via CSS.

@chipbennett
11 years ago

Alternate patch. Uses if/else rather than if/elseif, and more current-page-link as CSS class

#7 @chipbennett
11 years ago

  • Cc chip@… added

I was just going to open a ticket for this same issue, and found this one. So, I've attached my patch, in case it's helpful. Needless to say: this is much-needed for Theme developers, as targeting the current page element is all but impossible with the current markup being output.

#8 @nacin
11 years ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

@danielpataki
11 years ago

Alternate Patch For Issue - different class name

#9 @danielpataki
11 years ago

Hi All,

I've uploaded an alternate patch, I was wondering if it may be better to name the class differently. I think current-page-link is a better class name, however paginate_links() creates links which have the current class. In addition, I've added the class page-numbers to the individual links and the current span as well.

This way the output of this function will be compatible with the paginate_links() function which allows for standardized CSS when developing themes.

#10 @sinan-isler
10 years ago

  • Keywords needs-patch added; has-patch removed
  • Severity changed from normal to major
  • Summary changed from wp_link_pages() does not showing active element to wp_link_pages() does not showing active current element

Please add this on new release asap.
Dont wait more please...

Last edited 10 years ago by sinan-isler (previous) (diff)

#11 @billerickson
6 years ago

  • Keywords has-patch added; needs-patch removed

The patch works with WordPress 5.0 ( post-template.php.wp_link_pages.patch ) .

You can also use a filter to add this functionality within your theme. Ex: https://gist.github.com/billerickson/82ac2a970c1eaf5358c363c06cbee72f

I think it would be nice to have built into core, but isn't essential due to the existing filter.

Note: See TracTickets for help on using tickets.