Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
Last active March 27, 2018 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mypacecreator/b5ada75bac591d5167c222a08b90a928 to your computer and use it in GitHub Desktop.
Save mypacecreator/b5ada75bac591d5167c222a08b90a928 to your computer and use it in GitHub Desktop.
singleページの前後リンクの %link% 部分で、a要素の内側にさらにspanを入れる
<?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