Skip to content

Commit

Permalink
Fix broken category links when removing category base
Browse files Browse the repository at this point in the history
Calls to get_term_link() and get_category_link() should always return a full URL, but wpcom_vip_load_category_base() has been breaking that behaviour. This fix restores the correct functioning by using `home_url()` to ensure there is a full URL.
  • Loading branch information
philipjohn committed Oct 5, 2023
1 parent 90bd992 commit ed0b0c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vip-helpers/vip-permastructs.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function wpcom_vip_load_category_base( $new_category_base ) {
// For empty category base, remove the '/category/' from the base, but include the parent category if it's a child
if ( '' === $new_category_base ) {
add_filter( 'category_link', function ( $link, $term_id ) {
return '/' . get_category_parents( $term_id, false, '/', true );
return home_url( '/' . get_category_parents( $term_id, false, '/', true ) );

Check warning on line 49 in vip-helpers/vip-permastructs.php

View check run for this annotation

Codecov / codecov/patch

vip-helpers/vip-permastructs.php#L49

Added line #L49 was not covered by tests
}, 9, 2 );
}
}
Expand Down

0 comments on commit ed0b0c8

Please sign in to comment.