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

  • Resolved adowdle

    (@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: https://1ce.org/1#SkfsG8KYm

    Rolling back to the prior version fixed the issue.

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

    (@gamerz)

    Hmm I can’t reproduce this on my end on https://lesterchan.net/wordpress/. 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

    (@gamerz)

    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 https://github.com/lesterchan/wp-pagenavi/compare/8e593062522b30cfe5117e3f42b7129f10abf9d1..ba350b693b1325d92f0fdd9610cad51f2b097541 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 months, 1 week ago by  jkuzma.
    • This reply was modified 2 months, 1 week 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);

    with

    $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)
  • You must be logged in to reply to this topic.