pagination - Problem with Paging 404

admin2025-06-03  2

On my Wordpress site, house is a page with short code written in it to paginate a get terms loop.

Currently below urls works perfectly to return 2nd page of the loop

/house/?paged=2    
/index.php?pagename=house&paged=2

Then I added the below

function custom_rewrite_basic() {
add_rewrite_rule('^house/page/([0-9]+)/?$', 'index.php?pagename=house&paged=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic', 10, 0);

However /house/page/2/ still returns 404 not found.

On my Wordpress site, house is a page with short code written in it to paginate a get terms loop.

Currently below urls works perfectly to return 2nd page of the loop

/house/?paged=2    
/index.php?pagename=house&paged=2

Then I added the below

function custom_rewrite_basic() {
add_rewrite_rule('^house/page/([0-9]+)/?$', 'index.php?pagename=house&paged=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic', 10, 0);

However /house/page/2/ still returns 404 not found.

Share Improve this question edited Feb 9, 2019 at 12:41 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Feb 9, 2019 at 12:24 CalvinCalvin 757 bronze badges 2
  • Did you flush the rewrite rules? Settings -> Permalinks -> Save Changes without any changes. If so, another great debugging step for this kind of thing is to get the plugin wp query monitor, which will show a breakdown of all the rewrite rules WordPress considered in returning the page. You can verify your rule is showing up there at all. – tmdesigned Commented Feb 9, 2019 at 12:30
  • @tmdesigned you are right, I did not flush the rewrite rules by going to settings and resave permalinks. Now it is working. Thank you so much. – Calvin Commented Feb 9, 2019 at 12:49
Add a comment  | 

1 Answer 1

Reset to default 0

As answer provided by @tmdesigned in comments above.

An extra step is needed, to go to settings and resave permalinks.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748924617a314865.html

最新回复(0)