Site icon Hip-Hop Website Design and Development

Rewrite with pagination /foo/page/2/ to posts of a given category, page 2

This

add_action('init',  function() {
    add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top');
});

works and allows example.com/foo/ to display all the posts from category1.

But then the pagination doesn’t work.

There is a link on the bottom of this page that shows "Older posts", and that redirects to example.com/foo/page/2/.

Question: how to have example.com/foo/page/2/ display all the posts from category1, page 2?
(without a third party plugin)