Created
January 26, 2017 07:47
-
-
Save anegoda1995/583b060a097f6cb1a20e8b2b76ee6f94 to your computer and use it in GitHub Desktop.
Change HTML for wp_PageNavi plugin 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
###################### | |
# Change html pagenavi for transform like bootstrap | |
###################### | |
//attach our function to the wp_pagenavi filter | |
add_filter( 'wp_pagenavi', 'wd_pagination', 10, 2 ); | |
//customize the PageNavi HTML before it is output | |
function wd_pagination($html) { | |
$out = ''; | |
//wrap a's and span's in li's | |
$out = str_replace("<a","<li><a",$html); | |
$out = str_replace("</a>","</a></li>",$out); | |
$out = str_replace("<span","<li><span",$out); | |
$out = str_replace("</span>","</span></li>",$out); | |
$out = str_replace("<div class='wp-pagenavi'>","",$out); | |
$out = str_replace("</div>","",$out); | |
return '<div class="pagination"> | |
<ul>'.$out.'</ul> | |
</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you want to change class of , for example, you need to add str_replace between 13 and 14 rows.