Skip to content

Instantly share code, notes, and snippets.

@amin3d
Created August 23, 2016 13:08
Show Gist options
  • Save amin3d/ff4ed5477f21fada40ad21ff4673eaee to your computer and use it in GitHub Desktop.
Save amin3d/ff4ed5477f21fada40ad21ff4673eaee to your computer and use it in GitHub Desktop.
Bootstrap WordPress Pagination Using WP-Pagenavi
/*-------------------------------------------------------------------
Bootstrap WordPress Pagination Using WP-Pagenavi
-------------------------------------------------------------------*/
//attach our function to the wp_pagenavi filter
add_filter( 'wp_pagenavi', 'ik_pagination', 10, 2 );
//customize the PageNavi HTML before it is output
function ik_pagination($html) {
$out = '';
//wrap a's and span's in li's
$out = str_replace("<div","",$html);
$out = str_replace("class='wp-pagenavi'>","",$out);
$out = str_replace("<a","<li><a",$out);
$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>","",$out);
$out = str_replace("<li><span class='current'","<li class='active'><span",$out);
return '<nav>
<ul class="pagination">'.$out.'</ul>
</nav>';
}
/*-------------------------------------------------------------------
Bootstrap WordPress Pagination Using WP-Pagenavi
-------------------------------------------------------------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment