-
Notifications
You must be signed in to change notification settings - Fork 9
TypeWithArchive rewrite-rule should not be done if not archive page set #87
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
If no page_for_xxx is set, the archive_paged_rewrite function should not alter the rewrite rules as it leads to "catch all" rewrites.
superstack/wordpress/theme/lib/post-types/TypeWithArchive.php
Lines 177 to 198 in 3501664
| function archive_paged_rewrite($rules) { | |
| $cpt_name = $this->getName(); | |
| if($cpt_name === 'post') return $rules; // Bail early if it's a post (as the pagination rules already exist) | |
| $rule = array_filter($rules, function($regex) { | |
| return strpos( $regex, '([^/]+)/page' ) > -1; | |
| }, ARRAY_FILTER_USE_KEY); | |
| if ( empty($rule) ) return $rules; | |
| $new_regex = str_replace( '([^/]+)/page/', 'page/', array_keys($rule)[0] ); | |
| $new_regex = str_replace( '?:', '', $new_regex ); | |
| $archive_link = $this->get_archive_page_url(); | |
| $new_rules = array_merge([ | |
| $new_regex => 'index.php?pagename='.str_replace('/','',$archive_link).'&paged=$matches[1]', | |
| ], $rules); | |
| return $new_rules; | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
