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
- Display current category title on category page
- Modify previous and next text from pagination links
- Inject post (from specific category) between posts in Loop
- How can I modify the permalink via a filter?
- Preventing index.php?category_name=something from redirecting
- 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
- Can I write ‘RewriteCond’ using ‘functions.php’?
- List all categories but exclude current post category on single post page
- WordPress Rewrite API calls not creating new rules
- Edit category output
- Pagination problem
- Different background-image by category
- Page navigation not showing even tho it should
- Woocommerce – remove product from category
- How can I add pagination and how can I change thumbnail size?
- 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?
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Filter Select results based on selection
- Unreadable pagination
- 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
- How to pick the default selected value in wordpress dropdown?
- Get page that displays all children of taxonomy parent
- How to modify URL (add GET values) after front end form submission?
- How to show only subcategories in parent category not parent category?
- Redirect to another page using contact form 7? [closed]
- How to get all author posts outside of author templates
- Next post link on a bootstrap button
- How to override url params with rewrite rules vars?
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Generating rel=”prev” and rel=”next” using filters
- Post not populating for custom post type based on category selection
- Need help with Code Correction php+wordpress
- Need help with pagination
- How to add a rewrite endpoint to unattached media?
- Using rules in Posts
- Removing sidebar on category pages
- go to home page when i select default in select-box
- page 1 is not paged
- Custom url structure – pages under a custom post type
- How to work Woocommerce pagination inside shortcode?
- Wrong Number of Products When Hiding Subcategory Products From Showing In Parent Category
- How do I edit the terms output args or array data?
- Get main parent category for post (WordPress/Advanced Custom Fields)
- Display Visual Composer shortcode if a post belongs in specific categories
- How to stop hiding buttons forward / backward in pagination?
- How to make a pagination with dropdown selection?
- Category Page Displaying all Pages
- How to remove parent category from child category url using wordpress rewrite rule?
- How does Permalink work with the AMP plugin after Removing Parent Permalink Catalog from Posts
- Hide a specific category title from displaying on site
- Return to the beginning of the results of a for loop
- Exclude category and post from loop in custom category.php
- Admin backend, show post from a category and exclude the posts from subcategories
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- How to Retrieve All Category Images on Front-End
- Short code into PHP
- Need Quick Help With Product Category Page
- Need to adjust condition to say if I’m pulling categories from a post, to pull only the first one
- Apply filters when loading post via ajax
- offset and max_num_pages in pagination gallery
- Why isn’t my custom function kicking in from my functions.php file?
- Search in particular category in wordpress
- Is there a way to randomize and connect a background and header image?
- Error trying import one category on page
- Difference in Get Variable Location
- dynamically filter by category via sub-menu
- Code that displays images – images get shown multiple times
- Incomplete term slugs output from a foreach loop with get_the_terms
- WordPress post pagination on custom template not working
- Display post of specific category on page
- Displaying categories
- Product Category Page in Full Width
- Infinite Scroll Plugin: How to first show 6 posts and then 2 posts thereafter with Infinite Scroll Plugin?
- Pagination not working properly
- Display all categories (with link) of custom post type – WordPress
- Can’t assign menu parent id or menu item breaks