$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>pagination - Problem with Paging 404|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

pagination - Problem with Paging 404

matteradmin10PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far