WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 3 months ago

#24705 new enhancement

wp_link_pages() does not showing active current element

Reported by: Alexufo Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 2.2
Component: Posts, Post Types Keywords: dev-feedback needs-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 anand.potukuchi 22 months ago.
24705#.patch (607 bytes) - added by anand.potukuchi 22 months ago.
patched up awaiting review
24705.2.patch (596 bytes) - added by Frank Klein 21 months ago.
post-template.php.wp_link_pages.patch (687 bytes) - added by chipbennett 18 months 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 15 months ago.
Alternate Patch For Issue - different class name

Download all attachments as: .zip

Change History (15)

comment:1 @Alexufo22 months ago

  • Type changed from defect (bug) to enhancement

comment:2 @Alexufo22 months ago

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

comment:3 @anand.potukuchi22 months ago

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

Keywords' changed from needs_patch to has_patch

Last edited 22 months ago by anand.potukuchi (previous) (diff)

comment:4 @anand.potukuchi22 months ago

  • Keywords dev-feedback added

@anand.potukuchi22 months ago

comment:5 @SergeyBiryukov22 months ago

  • Component changed from General to Template

@anand.potukuchi22 months ago

patched up awaiting review

@Frank Klein21 months ago

comment:6 @Frank Klein21 months 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.

@chipbennett18 months ago

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

comment:7 @chipbennett18 months 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.

comment:8 @nacin15 months ago

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

@danielpataki15 months ago

Alternate Patch For Issue - different class name

comment:9 @danielpataki15 months 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.

comment:10 @sinan-isler3 months 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 3 months ago by sinan-isler (previous) (diff)
Note: See TracTickets for help on using tickets.