Support » Plugin: WP-PageNavi » Latest version bug with secondary query

  • Resolved adowdle


    This is what the latest version is outputting for my pagination on several sites: `<ul class=”pagination”> class=’wp-pagenavi’ role=’navigation’>
    You can see a screenshot here:

    Rolling back to the prior version fixed the issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Lester Chan


    Hmm I can’t reproduce this on my end on What settings are you using?

    I encounter the same issue with the latest version and had to roll back to the previous which resolved the issue. I am using a filter which may be part of whats causing the incompatibility. See below:

    add_filter( 'wp_pagenavi', 'cfmm_pagination', 10, 2 );
    function cfmm_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);
    	return '<ul class="pagination pagination-centered">'.$out.'</ul>';
    Plugin Author Lester Chan


    Ah! because you did an HTML replacement and hence it breaks. This is very brittle. The latest version introduces some markup for accessibility.

    You can see the changes and modify your filter accordingly.

    I’m using a similar filter as above and cannot go and update 50 websites that I’ve done for clients over the years. Whatever markup was introduced will break these websites unfortunately.

    I’d like to add that the reason for this filter is for compatibility with Bootstrap 3.

    • This reply was modified 2 years, 3 months ago by jkuzma.
    • This reply was modified 2 years, 3 months ago by jkuzma.

    A fix for sites you have access to the above function is as follows. Replace

    $out = str_replace("class='wp-pagenavi'>","",$out);


    $out = str_replace("class='wp-pagenavi' role='navigation'>","",$out);

    Hope this helps those who come across this thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Latest version bug with secondary query’ is closed to new replies.