Last active
March 27, 2018 08:59
-
-
Save mypacecreator/b5ada75bac591d5167c222a08b90a928 to your computer and use it in GitHub Desktop.
singleページの前後リンクの %link% 部分で、a要素の内側にさらにspanを入れる
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 | |
/** | |
* 前後リンクの出力部分で、a要素の内側にさらにspanを入れる | |
* | |
* @param string $link Link permalink format. | |
* | |
* @return string | |
*/ | |
function my_post_link( $link ) { | |
$link = preg_replace( '/<a href="(.+?)">(.+?)<\/a>/', '<a href="$1"><span>$2</span></a>', $link ); | |
return $link; | |
} | |
add_filter( 'previous_post_link', 'my_post_link' ); | |
add_filter( 'next_post_link', 'my_post_link' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment