Last active
March 27, 2018 09:00
-
-
Save mypacecreator/dfdaeb7fb0578136d1af991c26490a4e to your computer and use it in GitHub Desktop.
wp_list_categories の出力で、カレント表示のclass名の変更と、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 | |
/** | |
* wp_list_categories の出力を支給HTMLに合わせて変更 | |
* カレント表示のclass変更、a要素の内側にさらにspanを入れる | |
* | |
* @param string $output | |
* | |
* @return string | |
*/ | |
function my_wp_list_categories( $output ) { | |
$output = preg_replace( '/current-cat/', 'on', $output ); | |
$output = preg_replace( '/<a href="(.+?)" >(.+?)<\/a>/', '<a href="$1"><span>$2</span></a>', $output ); | |
return $output; | |
} | |
add_filter( 'wp_list_categories', 'my_wp_list_categories' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment