Skip to content

Commit 9a77922

Browse files
committed
Ensure a query object is known before attempting to get its URL
1 parent 2e5ea36 commit 9a77922

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎source/wp-content/themes/wporg-showcase-2022/functions.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,10 @@ function add_social_meta_tags() {
461461
];
462462

463463
if ( is_tag() || is_category() ) {
464-
$og_fields['og:url'] = esc_url( get_term_link( get_queried_object_id() ) );
464+
$queried_object_id = get_queried_object_id();
465+
if ( $queried_object_id ) {
466+
$og_fields['og:url'] = esc_url( get_term_link( $queried_object_id ) );
467+
}
465468
} elseif ( is_single() ) {
466469
$og_fields['og:description'] = strip_tags( get_the_excerpt() );
467470
$og_fields['og:url'] = esc_url( get_permalink() );

0 commit comments

Comments
 (0)