Created
July 31, 2023 14:29
-
-
Save TimBHowe/1604b163230337a5d3a312f8e1c7599b to your computer and use it in GitHub Desktop.
Add 'rel="next"' and 'rel="prev"' attribute to the next and previous links in the paginate_links function in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Alter the pagination next and prev links to have rel. | |
* | |
* @param string $r HTML output. | |
* @param array $args An array of arguments. See paginate_links() for information on accepted arguments. | |
* | |
* @return sting - The HTML output of the pagination. | |
*/ | |
function scaffolding_add_rel_pagination( $r, $args ) { | |
$r = str_replace( 'class="prev', 'rel="prev" class="prev', $r ); | |
$r = str_replace( 'class="next', 'rel="next" class="next', $r ); | |
return $r; | |
} | |
add_filter( 'paginate_links_output', 'scaffolding_add_rel_pagination', 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment