diff --git a/src/PostData.php b/src/PostData.php index 913fb97..ca77bec 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->postType())) { + return ''; + } + return \get_permalink($this->id) ?: ''; } }