Make WordPress Core

Opened 13 years ago

Closed 7 months ago

#24705 closed enhancement (wontfix)

wp_link_pages() does not showing active current element

Reported by: alexufo's profile Alexufo Owned by:
Milestone: Priority: normal
Severity: major Version:
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 13 years ago.
24705#.patch (607 bytes) - added by anonymized_10276468 13 years ago.
patched up awaiting review
24705.2.patch (596 bytes) - added by anonymized_8769252 13 years ago.
post-template.php.wp_link_pages.patch (687 bytes) - added by chipbennett 12 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 12 years ago.
Alternate Patch For Issue - different class name

Download all attachments as: .zip

Change History (17)

#1 @Alexufo
13 years ago

  • Type changed from defect (bug) to enhancement

#2 @Alexufo
13 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
13 years ago

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

Keywords' changed from needs_patch to has_patch

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

#4 @anonymized_10276468
13 years ago

  • Keywords dev-feedback added

#5 @SergeyBiryukov
13 years ago

  • Component changed from General to Template

@anonymized_10276468
13 years ago

patched up awaiting review

#6 @anonymized_8769252
13 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
12 years ago

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

#7 @chipbennett
12 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
12 years ago

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

@danielpataki
12 years ago

Alternate Patch For Issue - different class name

#9 @danielpataki
12 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
11 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 11 years ago by sinan-isler (previous) (diff)

#11 @billerickson
7 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.

#12 @SirLouen
7 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version 2.2 deleted

As @billerickson commented, adding code having the filter makes this not strictly necessary and given that this report has completely lost the traction and the fact that we are progressing into newer grounds, it doesn't seem to be a good enhancement for now. For all of these reasons, I'm closing this as wontfix

Note: See TracTickets for help on using tickets.