From 0cda2944fb43e13c4966fdc10f0cf6a1e2290625 Mon Sep 17 00:00:00 2001 From: Kyle Hotchkiss <108172+kylehotchkiss@users.noreply.github.com> Date: Fri, 1 Oct 2021 22:13:07 +0530 Subject: [PATCH] resolve bug where clicking 'view' in wp-admin leads to a broken redirect --- .../themes/headless/setup/helpers/headless-redirect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordpress/wp-content/themes/headless/setup/helpers/headless-redirect.php b/wordpress/wp-content/themes/headless/setup/helpers/headless-redirect.php index 5600dc0..e76e644 100644 --- a/wordpress/wp-content/themes/headless/setup/helpers/headless-redirect.php +++ b/wordpress/wp-content/themes/headless/setup/helpers/headless-redirect.php @@ -5,7 +5,7 @@ function headless_redirect(){ $preview_secret = defined('WORDPRESS_PREVIEW_SECRET') ? WORDPRESS_PREVIEW_SECRET : ''; $post_type = get_post_type(get_the_ID()); - $slug = str_replace(home_url(), '', get_permalink(get_the_ID())); + $slug = ltrim(str_replace(home_url(), '', get_permalink(get_the_ID())), '/'); $redirect = ''; // check if preview and user has edit ability. // if so, redirect to preview path