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
- Change the “page” slug in pagination
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- Allow authors to post only in categories they create in WordPress
- Changing Link Attributes for Wp_Link_Pages
- Categories Template Assistance
- WordPress Rewrite API calls not creating new rules
- Add ‘articles’ prefix before blog posts url without affecting pagination
- Use template for posts with a particular category grandparent
- Custom Loop through category menu to include sub categories
- Get posts with at least one category in common with current post?
- Page navigation not showing even tho it should
- Woocommerce – remove product from category
- Get category name from custom loop and echo it once
- hover image appears below placeholder instead of overlayed
- get current product name in functions.php
- WP-PageNavi is showing the first page only
- How to change home or site url using action hooks or filter?
- Filter Select results based on selection
- How to change category and year archive permalinks/rewrite rules?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- How to show single category archive
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- subdirectory index.php is not working
- Taxonomy Pagination Rewrite
- Search not showing all results
- Hide subcategories (widget)
- Let Users Choose Post Categories
- How to show only subcategories in parent category not parent category?
- WordPress add_rewrite_rules for custom URLs ending in .html
- Display most popular posts of category
- get taxonomy thumbnail and use it as a variable in code
- Custom Pagination is Broken
- Get latest post from all categories except one
- Prev/Next Links Broken on Static Front Page Pagination
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- Argument for if term-> have child?
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- How do i add slugs to a URL, but still redirecting to the same page
- Custom post type url Rewrite (conflicting with page url)
- Pagination for custom post types – url rewriting
- is user member of a group, show them categories [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- pagination broken – clicking next displays “page not found”
- Finding and removing duplicates within WP Arrays
- Compare current post Category in select menu
- Pagination Not Working (pages duplicating content)
- Why is home page content not displaying with this rewrite rule?
- Get the list of post categories
- Woocommerce. Get a list of products in the current category on the archive page and product page
- How to show categories and date on posts
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Allow two posts (from different categories) to have the same slug
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Child-Theme Category View with modified permalinks (%category% removed)
- WordPress rewrite rule depend on meta values not ids
- How to enable HTML tags in category description without breaking the category page
- Trying to show the category of a post in the post display
- Trying to get pagination working on WP_Query() post grid
- Pagination 404 error(I have refreshed the permalinks and tried several previous options)
- Rewrite URL of Specific Post of Custom Type
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Code works on page-example.php by not category-example.php
- get_category display only 1
- How to list categories by page id in wordpress
- WordPress using get_term to retreive slug not working as expected
- Showing the project type in HREF
- Paging not working for hierarchical custom post type
- Front end post submissions do not get submitted in the category
- WordPress pagination broken on blog page, working for search results page
- How to print redirected query string variables to the page?
- Make an array listing custom taxonomy
- Category foreach Paging
- Get category id for a custom category and display it in a class
- Multiple URL from Custom post name
- Trying to exclude posts from a category on the home page
- how to exclude admin page from add_rewrite_rule in wordpress
- Pagination on Custom Loop
- wp_get_archive for category returning different URLs on different but similar sites
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- How to insert the first letter in uppercase [closed]