Solved with:
add_rewrite_rule('^foo/page/([0-9]+)/?$', 'index.php?category_name=category1&paged=$matches[1]', 'top');
add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top');
The order between these two lines here is important.
See also Permalink/Pagination issue: Category base name same as page name.
Related Posts:
- Newbie question: no index.php? in my plain wordpress permalink
- Static variable and add_rewrite_rule?
- Performance impact of rewriting WordPress URLs
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- Append query string to all URL’s
- custom rewrite rule help! Custom rewrite rules not applying to custom post type
- Create custom permalinks to show Custom Post Type’s relationship?
- WordPress Rewrite Rule
- Pagination at category doesnt work with same name of page
- Exclude a category slug on pagination
- rewrite_rule – working fine but broken for pagination
- WordPress add parameters with friendly url structure
- wordpress category rewrite rule with pagination
- How to Dynamically Change the author_base URL Slug by Language in WordPress?
- get post based on category chosen in drop down – The ajax method
- How to use transient in this code for related post?
- Nesting if statements to echo only one string based on what tag was filtered?
- Creating a related post section based on similar categories
- Swapping wp_dropdown_categories function with wp_category_checklist
- WP-PageNavi is showing the first page only
- Disable Pagination on Pages
- How can I properly control the numbers and dots that appear in pagination?
- Increase returned number/pages on pagination
- How to change home or site url using action hooks or filter?
- Proper syntax or method for keeping url in modified isotope / category links
- Adding nofollow to a PHP generated Nav
- Apache Fallback instead of add_rewrite_rule
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Filter Select results based on selection
- Using loop pagination on single.php
- WordPress 3.2 query_posts and pagination, permalinks issue
- Is sanitize_title_with_dashes formatting function too liberal (in terms of accepted characters)?
- What is an equivalent of single_cat_title for getting the slug of the category?
- Unreadable pagination
- Issue adding sub category programmatically
- How to change category and year archive permalinks/rewrite rules?
- Changed pagination URLS to use p= instead of paged=
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Move category description below post list in blog
- How to pick the default selected value in wordpress dropdown?
- How to show all pages in blog navigation?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- get_terms pagination
- Get page that displays all children of taxonomy parent
- selected option if current category is the value
- subdirectory index.php is not working
- custom url rewrite for wordpress
- Taxonomy Pagination Rewrite
- Use URL Rewrite as well as $_GET parameters in URL?
- How to modify URL (add GET values) after front end form submission?
- get_template_part based upon post’s category
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- parts of url disappear when using # inside href=”” [closed]
- Search not showing all results
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- Pagination in plugin’s backend
- Add .htm extention to a custom taxonomy
- How to show only subcategories in parent category not parent category?
- Help with .htaccess and Login with Subfolders
- PHP code to use on next & previouspage links
- Pagination for custom shop loop woocommerce
- how to show only specific category for a template
- Redirect to another page using contact form 7? [closed]
- WordPress add_rewrite_rules for custom URLs ending in .html
- Dilemma of Populating all the categories in a drop down list
- Display most popular posts of category
- Adding a rewrite rule to page that has no fixed variables and pagination
- How to get all author posts outside of author templates
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to create pagination for users list using custom array?
- Custom Pagination is Broken
- How to array only one key from another array
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- website with pretty permalinks except pagination
- Pagination on Custom Post
- Get all categories post is not in
- Next post link on a bootstrap button
- Get latest post from all categories except one
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Displaying posts based on category
- Prev/Next Links Broken on Static Front Page Pagination