Skip to content

Commit

Permalink
Block theme: Prevent category archive redirect on favorites & author …
Browse files Browse the repository at this point in the history
…archive pages.

Fixes #663, fixes #668
  • Loading branch information
ryelle committed Apr 15, 2024
1 parent 9cc3962 commit 4744714
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ function redirect_term_archives() {
// True on the `/tag/…` URLs, and false on `/archive/?tag…` URLs.
$is_term_archive = is_tag() || is_category() || is_tax();

// Don't redirect on favorites or author archives.
$bypass_redirect = is_page( 'favorites' ) || is_author();
if ( $bypass_redirect ) {
return;
}

// If there is only one term applied, and we're not already on a term
// archive, redirect to the main term archive URL.
if ( count( $terms ) === 1 && ! $is_term_archive ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ function add_site_navigation_menus( $menus ) {
if ( in_array( $term->slug, $current_cats ) ) {
$cat['className'] = 'current-menu-item';
}
if ( is_page( 'favorites' ) ) {
$cat['url'] = add_query_arg( 'pattern-categories', $term->slug, get_permalink() );
if ( is_page( 'favorites' ) || is_author() ) {
global $wp;
$cat['url'] = add_query_arg( 'pattern-categories', $term->slug, home_url( $wp->request ) );
}

$categories[] = $cat;
Expand Down

0 comments on commit 4744714

Please sign in to comment.