[wp-trac] [WordPress Trac] #45920: Twenty Nineteen: Add fragment ID to paginated links
WordPress Trac
noreply at wordpress.org
Thu Jan 10 19:10:32 UTC 2019
#45920: Twenty Nineteen: Add fragment ID to paginated links
---------------------------+-----------------------------
Reporter: laurelfulford | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bundled Theme | Version: 5.0.2
Severity: normal | Keywords: needs-patch
Focuses: |
---------------------------+-----------------------------
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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45920>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list