Skip to content

Commit 11c3301

Browse files
Taxonomies metatag behaviour fixed (#152)
Retrieve meta tag values defined on taxonomies via Yoast plugin in GraphQL queries.
1 parent e91fd80 commit 11c3301

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

wp-graphql-yoast-seo.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
}
1919

2020
use WPGraphQL\AppContext;
21+
use WPGraphQL\Model\Term;
2122

2223
add_action('admin_init', function () {
2324
$core_dependencies = [
@@ -750,7 +751,11 @@ function get_post_type_graphql_fields($post, array $args, AppContext $context)
750751
'@graph' => 'graph',
751752
'@context' => 'context',
752753
];
753-
$meta = YoastSEO()->meta->for_post($post->ID);
754+
if( $post instanceof Term ){
755+
$meta = YoastSEO()->meta->for_term($post->term_id);
756+
} else {
757+
$meta = YoastSEO()->meta->for_post($post->ID);
758+
}
754759

755760
$schemaArray = $meta !== false ? $meta->schema : [];
756761

0 commit comments

Comments
 (0)