From 0449c3f74801718d6cd40401cd3d25084fffd235 Mon Sep 17 00:00:00 2001 From: Ash Hitchcock Date: Thu, 30 Apr 2020 20:42:04 +0100 Subject: [PATCH] terms --- wp-graphql-yoast-seo.php | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/wp-graphql-yoast-seo.php b/wp-graphql-yoast-seo.php index 2264845..87ccc83 100755 --- a/wp-graphql-yoast-seo.php +++ b/wp-graphql-yoast-seo.php @@ -308,39 +308,26 @@ function get_og_image($images) $term_obj = get_term($term->term_id); - query_posts( - array( - 'tax_query' => array( - array( - 'taxonomy' => $term_obj->taxonomy, - 'terms' => $term_obj->term_id, - 'field' => 'term_id' - ) - ) - ) - ); - the_post(); - - $meta = WPSEO_Taxonomy_Meta::get_term_meta((int) $term_obj->term_id, $term_obj->taxonomy); + $robots = YoastSEO()->meta->for_term($term->term_id)->robots; // Get data $seo = array( - 'title' => trim(YoastSEO()->meta->for_post($post->ID)->title), - 'metaDesc' => trim(YoastSEO()->meta->for_post($post->ID)->description), + 'title' => trim(YoastSEO()->meta->for_term($term->term_id)->title), + 'metaDesc' => trim(YoastSEO()->meta->for_term($term->term_id)->description), 'focuskw' => trim($meta['wpseo_focuskw']), 'metaKeywords' => trim($meta['wpseo_metakeywords']), - 'metaRobotsNoindex' => trim($meta['wpseo_meta-robots-noindex']), - 'metaRobotsNofollow' => trim($meta['wpseo_meta-robots-nofollow']), - 'opengraphTitle' => trim(YoastSEO()->meta->for_post($post->ID)->open_graph_title), - 'opengraphType' => trim(YoastSEO()->meta->for_post($post->ID)->open_graph_type), - 'opengraphAuthor' => trim(YoastSEO()->meta->for_post($post->ID)->open_graph_article_author), - 'opengraphPublisher' => trim(YoastSEO()->meta->for_post($post->ID)->open_graph_article_publisher), - 'opengraphDescription' => trim(YoastSEO()->meta->for_post($post->ID)->open_graph_description), + 'metaRobotsNoindex' => $robots['index'], + 'metaRobotsNofollow' => $robots['follow'], + 'opengraphTitle' => trim(YoastSEO()->meta->for_term($term->term_id)->open_graph_title), + 'opengraphType' => trim(YoastSEO()->meta->for_term($term->term_id)->open_graph_type), + 'opengraphAuthor' => trim(YoastSEO()->meta->for_term($term->term_id)->open_graph_article_author), + 'opengraphPublisher' => trim(YoastSEO()->meta->for_term($term->term_id)->open_graph_article_publisher), + 'opengraphDescription' => trim(YoastSEO()->meta->for_term($term->term_id)->open_graph_description), 'opengraphImage' => DataSource::resolve_post_object($meta['wpseo_opengraph-image-id'], $context), - 'twitterCardType' => trim(YoastSEO()->meta->for_post($post->ID)->twitter_card), - 'twitterTitle' => trim($meta['wpseo_twitter-title']), - 'twitterDescription' => trim($meta['wpseo_twitter-description']), + 'twitterCardType' => trim(YoastSEO()->meta->for_term($term->term_id)->twitter_card), + 'twitterTitle' => trim(YoastSEO()->meta->for_term($term->term_id)->twitter_title), + 'twitterDescription' => trim(YoastSEO()->meta->for_term($term->term_id)->twitter_description), 'twitterImage' => DataSource::resolve_post_object($meta['wpseo_twitter-image-id'], $context), 'canonical' => trim($meta['canonical']) );