From cfed8cd9029bc9fe353b7e8c17d17e2ac9779be0 Mon Sep 17 00:00:00 2001 From: rivanuff Date: Wed, 2 Jul 2025 11:05:40 +0200 Subject: [PATCH 1/3] (fix): don't return url for cpt's with publicly_queryable false --- src/PostData.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PostData.php b/src/PostData.php index 913fb97..b808680 100644 --- a/src/PostData.php +++ b/src/PostData.php @@ -293,6 +293,11 @@ public function url(): string return ''; } + // Don't return URL for CPT's with publicly_queryable => false + if ($this->postType() != 'page' && $this->postType() != 'post' && ! is_post_type_viewable($this->id)) { + return ''; + } + return \get_permalink($this->id) ?: ''; } } From df05d4758da0d157ac2eb5056e4c5f024120322b Mon Sep 17 00:00:00 2001 From: rivanuff <16398970+rivanuff@users.noreply.github.com> Date: Wed, 2 Jul 2025 09:08:33 +0000 Subject: [PATCH 2/3] (auto): apply php-cs-fixer changes --- src/PostData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PostData.php b/src/PostData.php index b808680..8aa0f83 100644 --- a/src/PostData.php +++ b/src/PostData.php @@ -293,7 +293,7 @@ public function url(): string return ''; } - // Don't return URL for CPT's with publicly_queryable => false + // Don't return URL for CPT's with publicly_queryable => false if ($this->postType() != 'page' && $this->postType() != 'post' && ! is_post_type_viewable($this->id)) { return ''; } From 49975ce618167464d8f314438499a8620f198643 Mon Sep 17 00:00:00 2001 From: rivanuff Date: Wed, 2 Jul 2025 11:11:21 +0200 Subject: [PATCH 3/3] (fix): post type instead of id as arg (oops) --- src/PostData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PostData.php b/src/PostData.php index 8aa0f83..ca77bec 100644 --- a/src/PostData.php +++ b/src/PostData.php @@ -294,7 +294,7 @@ public function url(): string } // Don't return URL for CPT's with publicly_queryable => false - if ($this->postType() != 'page' && $this->postType() != 'post' && ! is_post_type_viewable($this->id)) { + if ($this->postType() != 'page' && $this->postType() != 'post' && ! is_post_type_viewable($this->postType())) { return ''; }