Title: Changing the class and HTML structure
Last modified: February 24, 2020

---

# Changing the class and HTML structure

 *  Resolved [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/changing-the-class-and-html-structure/)
 * I used this code for few years but seems to have stopped working.
 *     ```
       ######################
       #  	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>';
       }
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * (@hchouhan)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/changing-the-class-and-html-structure/#post-12475161)
 * Was able to fix it. Did not notice the args had changed. The working code is:
 *     ```
       	add_filter( 'wp_pagenavi', 'flattrendz_showcase_pagination', 10, 2 );
   
       	//customize the PageNavi HTML before it is output
       	function flattrendz_showcase_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","ul",$out);
   
       		return '<div class="pagination pagination-centered">
       				'.$out.'
       			</div>';
       	}
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Changing the class and HTML structure’ is closed to new replies.

 * ![](https://ps.w.org/wp-pagenavi/assets/icon.svg?rev=977997)
 * [WP-PageNavi](https://wordpress.org/plugins/wp-pagenavi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-pagenavi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-pagenavi/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-pagenavi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-pagenavi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-pagenavi/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Harish Chouhan](https://wordpress.org/support/users/hchouhan/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/changing-the-class-and-html-structure/#post-12475161)
 * Status: resolved