From ed0b0c8b7a1c311593685463fb28cb465b60d8a3 Mon Sep 17 00:00:00 2001 From: Philip John Date: Thu, 5 Oct 2023 11:10:33 +0100 Subject: [PATCH] Fix broken category links when removing category base 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. --- vip-helpers/vip-permastructs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vip-helpers/vip-permastructs.php b/vip-helpers/vip-permastructs.php index 6dc368aabd..bc9d9f6a13 100644 --- a/vip-helpers/vip-permastructs.php +++ b/vip-helpers/vip-permastructs.php @@ -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 ) ); }, 9, 2 ); } }