Opened 11 months ago
Last modified 11 months ago
#45920 new enhancement
Twenty Nineteen: Add fragment ID to paginated links
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.0.2 |
Component: | Bundled Theme | Keywords: | has-patch needs-testing |
Focuses: | Cc: | ||
PR Number: |
Description
Originally reported by @joyously in the Twenty Nineteen GitHub repo:
When the post/page has a featured image and is paginated, it shows the big image on each page.
That is fine, but we could use code such as this so that the page links go to #content
.
/** * Add a fragment identifier (to the content) to paginated links. */ function twentynineteen_link_pages_link( $link, $i ) { if ( $i > 1 && preg_match( '/href="([^"]*)"/', $link, $matches ) ) { if ( false === strpos( $matches[1], '#' ) ) { $link = str_replace( $matches[1], $matches[1] . '#content', $link ); } } return $link; } add_filter( 'wp_link_pages_link', 'twentynineteen_link_pages_link', 10, 2 );
Original ticket: https://github.com/WordPress/twentynineteen/issues/381
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
@laurelfulford and @joyously above code is not working for Plain permalink structure. please try below code also attached patch for same in theme.