Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need more help with .html rewrite WordPress

  • SOLVED

I recently used this site to solve an issue with a .html rewrite. You can read that thread [[LINK href="http://wpquestions.com/question/showLoggedIn/id/7082"]]here[[/LINK]]. The code I ended up with is at the bottom of this post.

Recently I realized that the pagination of archive pages isn't working with the rewrites the way it is. When I use the "next page" (or whatever other option I set it to) the other pages all 404. I disabled this code and the pagination works fine, so I know it has something to do with this.

So how do I fix the pagination without?

PS, I am on Genesis framework and using there default paging



// Rewrite WordPress URLs to include .html endings
add_action('init', 'html_page_permalink', -1);
function html_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
}
add_filter('user_trailingslashit', 'no_page_slash',66,2);
function no_page_slash($string, $type){
global $wp_rewrite;
if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
return untrailingslashit($string);
}else{
return $string;
}
}

// Exclude the /blog/ page from .hmtl rewrites
function my_insert_rewrite_rules( $rules ) {
$newrules = array();
$newrules['^blog$'] = 'index.php?post_type=post';
return $newrules + $rules;
}
add_filter('rewrite_rules_array','my_insert_rewrite_rules');

Answers (1)

2012-10-10

Dbranes answers:

maybe you could try to add this rule

$newrules['^blog/page/?([0-9]{1,})?$'] = 'index.php?post_type=post&paged=$matches[1]';


i.e. in this function:

function my_insert_rewrite_rules( $rules ) {
$newrules = array();
$newrules['^blog$'] = 'index.php?post_type=post';
$newrules['^blog/page/?([0-9]{1,})?$'] = 'index.php?post_type=post&paged=$matches[1]';
return $newrules + $rules;
}


and then save the permalinks.


Sirmontegu comments:

That did the trick. Thanks!