This is an extension to the WPGraphQL plugin for Yoast SEO

Overview

WPGraphQl Yoast SEO Plugin

Latest Stable Version Total Downloads Monthly Downloads

WPGraphQl Yoast SEO Plugin

Please note version 14 of the Yoast Plugin is a major update.

If you are stuck on version of Yoast before V14 then use v3 of this plugin.

This is an extension to the WPGraphQL plugin (https://github.com/wp-graphql/wp-graphql) that returns Yoast SEO data.

Using this plugin? I would love to see what you make with it. 😃 @ash_hitchcock

Currently returning SEO data for:

  • Pages
  • Posts
  • Custom post types
  • Products (WooCommerce)
  • Categories
  • Custom taxonomies
  • WooCommerce Products
  • Yoast Configuration
    • Webmaster verification
    • Social profiles
    • Schemas
    • Breadcrumbs

If there is any Yoast data that is not currently returned, please raise an issue so we can add it to the roadmap.

Quick Install

  • Install from the WordPress Plugin Directory
  • Clone or download the zip of this repository into your WordPress plugin directory & activate the WP GraphQL Yoast SEO plugin
  • Install & activate WPGraphQL

Composer

composer require ashhitch/wp-graphql-yoast-seo

Find this useful?

Buy Me A Coffee

Canonicals

Please note canonicals will not be returned if you have the discourage search engines option turned on in your WordPress settings.

V4 breaking change

Plugin now requires at least Yoast 14.0.0

V3 breaking change

Image urls are now returned as mediaItem type.

This applies to twitterImage and opengraphImage

Usage with Gatsby

Checkout the companion Gatsby plugin to add in Metadata and JSON LD schema with ease.

Usage

To query for the Yoast Data simply add the seo object to your query:

Post Type Data

query GetPages {
    pages(first: 10) {
        edges {
            node {
                id
                title
                seo {
                    canonical
                    title
                    metaDesc
                    focuskw
                    metaRobotsNoindex
                    metaRobotsNofollow
                    opengraphAuthor
                    opengraphDescription
                    opengraphTitle
                    opengraphDescription
                    opengraphImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    opengraphUrl
                    opengraphSiteName
                    opengraphPublishedTime
                    opengraphModifiedTime
                    twitterTitle
                    twitterDescription
                    twitterImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    breadcrumbs {
                        url
                        text
                    }
                    cornerstone
                    schema {
                        pageType
                        articleType
                        raw
                    }
                    readingTime
                    fullHead
                }
                author {
                    node {
                        seo {
                            metaDesc
                            metaRobotsNofollow
                            metaRobotsNoindex
                            title
                            social {
                                youTube
                                wikipedia
                                twitter
                                soundCloud
                                pinterest
                                mySpace
                                linkedIn
                                instagram
                                facebook
                            }
                        }
                    }
                }
            }
        }
    }
}

Post Taxonomy Data

query GetCategories {
    categories(first: 10) {
        edges {
            node {
                id
                seo {
                    fullHead
                    canonical
                    title
                    metaDesc
                    focuskw
                    metaRobotsNoindex
                    metaRobotsNofollow
                    opengraphAuthor
                    opengraphDescription
                    opengraphTitle
                    opengraphDescription
                    opengraphImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    twitterTitle
                    twitterDescription
                    twitterImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    breadcrumbs {
                        url
                        text
                    }
                }
                name
            }
        }
    }
}

User Data

query GetUsers {
    users {
        nodes {
            seo {
                metaDesc
                metaRobotsNofollow
                metaRobotsNoindex
                title
                fullHead
                social {
                    youTube
                    wikipedia
                    twitter
                    soundCloud
                    pinterest
                    mySpace
                    linkedIn
                    instagram
                    facebook
                }
            }
        }
    }
}

Edge and Page Info Data

query GetPostsWithIsPrimary {
    posts {
        pageInfo {
            startCursor
            seo {
                schema {
                    raw
                }
            }
        }
        nodes {
            title
            slug
            categories {
                edges {
                    isPrimary
                    node {
                        name
                        count
                    }
                }
            }
        }
    }
}

Yoast Config Data

query GetSeoConfig {
    seo {
        webmaster {
            googleVerify
            yandexVerify
            msVerify
            baiduVerify
        }
        schema {
            siteName
            wordpressSiteName
            siteUrl
            inLanguage
            companyName
            companyOrPerson
            companyLogo {
                mediaItemUrl
            }
            logo {
                mediaItemUrl
            }
            personLogo {
                mediaItemUrl
            }
        }
        breadcrumbs {
            showBlogPage
            separator
            searchPrefix
            prefix
            homeText
            enabled
            boldLast
            archivePrefix
            notFoundText
        }
        social {
            facebook {
                url
                defaultImage {
                    mediaItemUrl
                }
            }
            instagram {
                url
            }
            linkedIn {
                url
            }
            mySpace {
                url
            }
            pinterest {
                url
                metaTag
            }
            twitter {
                cardType
                username
            }
            wikipedia {
                url
            }
            youTube {
                url
            }
        }
        openGraph {
            frontPage {
                title
                description
                image {
                    altText
                    sourceUrl
                    mediaItemUrl
                }
            }
            defaultImage {
                altText
                sourceUrl
                mediaItemUrl
            }
        }
        contentTypes {
            post {
                title
                schemaType
                metaRobotsNoindex
                metaDesc
                schema {
                    raw
                }

                archive {
                    fullHead
                    archiveLink
                    breadcrumbTitle
                    hasArchive
                    metaDesc
                    metaRobotsNoindex
                    title
                }
            }
            page {
                metaDesc
                metaRobotsNoindex
                schemaType
                title
                schema {
                    raw
                }
            }
        }
        redirects {
            origin
            target
            format
            type
        }
    }
}

Support

Open an issue

Twitter: @ash_hitchcock

Please Note: Yoast and WPGraphQL and their logos are copyright to their respective owners.

Comments
  • Page & Custom Post SEO Returns Null

    Page & Custom Post SEO Returns Null

    The plugin is exposing & returning post SEO fields but not returning field values pages or custom post types. Why can't figure out why.

    Using 4.8.0 of the plugin Yoast version 15.3 WPGraphQL 1.1.3 gatsby-source-wordpress 4.0.1

    Example Query:

      pages {
        edges {
          node {
            id
            title
            seo {
              canonical
              title
              metaDesc
              focuskw
              metaRobotsNoindex
              metaRobotsNofollow
              opengraphAuthor
              opengraphDescription
              opengraphTitle
              opengraphDescription
              opengraphImage {
                altText
                sourceUrl
                srcSet
              }
              opengraphUrl
              opengraphSiteName
              opengraphPublishedTime
              opengraphModifiedTime
              twitterTitle
              twitterDescription
              twitterImage {
                altText
                sourceUrl
                srcSet
              }
              breadcrumbs {
                url
                text
              }
              cornerstone
              schema {
                pageType
                articleType
              }
            }
          }
        }
      }
    }```
    opened by tomwhita 11
  • opengraphImage and twitterImage not showing in API

    opengraphImage and twitterImage not showing in API

    Hi,

    I have a page with both, the opengraph image and twitter image set, but both fields, opengraphImage and twitterImage show up as null in the API.

    I have looked at the code and found the following problems: The value for YoastSEO()->meta->for_post($post->ID)->open_graph_images, which is used to retrieve the value for the open graph image, returns the images as an array or arrays. From the first image in the array, the url is taken and then put through wp's attachment_url_to_postid function to retrieve the id. Unfortunately, the URL in the array is a scaled Version of the original image, meaning that it has the dimensions of the thumbnail attached to the original filename (eg. my-image-1640x680.jpg). The attachment_url_to_postid function can't find the media attachment with this URL and returns 0, resulting in a null value for the API.

    A similar problem exists for the twitter image, where the YoastSEO()->meta->for_post($post->ID)->twitter_image call returns a scaled version of the image, resulting in a return value of 0 from the attachment_url_to_postid function.

    The problem with opengraphImage could possibly be overcome by using one of the other values in the image array. In my example, the array contains an id field, which could be used directly. However, I'm unsure if this value is always available.

    I would also like to ask, wether it is necessary to return the images as MediaItems instead of as simple URLs. Yoast returns the scaled versions of the images, since they are optimized for the specific use-case. By expanding them back to MediaItems, the implementation that uses the information needs to re-decide which size to use.

    I can offer to implement the changes if you like, but wanted to discuss the topic before creating a pull request.

    Thank you for a great plugin!

    bug question Stale 
    opened by Mactory 10
  • Add dynamic meta data

    Add dynamic meta data

    Does this plugin still work with wp-graphql 0.3.2 (after the major 0.3.0 overhaul)? I did a quick test and it seems the graphql queries only return data when you manually edited the meta tags with the plugin. All autogenerated Yoast entries are empty strings

    enhancement 
    opened by shendriksza 10
  • Returning social images

    Returning social images

    Firstly, great work on the plugin so far.

    I had a suggestion around the social images (Open Graph and Twitter) that get returned. It would be great if we could return them as as a meditaItem. At the moment, they're just being returned as strings that point back to the WordPress instance, rather than Gatsby locally.

    I had a go at getting this working but couldn't crack it. I figure we could use the type MediaItem rather than String but I just couldn't find enough documentation around what I actually needed to pass to it.

    At the moment, I can see the plugin is using _yoast_wpseo_opengraph-image to grab the URL and I also see in the database that _yoast_wpseo_opengraph-image-id is available to get the ID of the media item. Just can't tie it all together. I'll submit a PR though if I get it figured out!

    enhancement 
    opened by nathobson 9
  • Request: JSON+LD for individual posts.

    Request: JSON+LD for individual posts.

    Yoast puts Json+ld automatically in the article generated by wordpress itself. It would be awesome if the same Json+ld object is automatically available in the post's seo.

    enhancement 
    opened by 1mursaleen 8
  • Problem returning excerpt in meta Desc

    Problem returning excerpt in meta Desc

    Using %%excerpt%% as the default description on a custom post type don't return the generated value. In editor & WP frontend it works image

    in my GQL query i get

    "seo": {
            "title": "Stable Baselines",
            "metaDesc": "%%excerpt%%",
    

    Any ideas?

    bug Yoast 14 
    opened by Mindgames 8
  • Special characters printing out like & and •

    Special characters printing out like & and •

    I'm not sure if this is specific to just the title tag field, but I've got an ampersand and bullet character in my title tags and they're showing up as & and • after fetching from GraphQL.

    bug 
    opened by justinradomski 8
  • Page SEO returns encoded special characters

    Page SEO returns encoded special characters

    Looks like I'm getting encoded special characters for page. Thought this might have been fixed in the past but seems to be broken again.

    Here's my query and what it returns. image

    Example shown is requesting titles but same issue occurs when requesting desc's Let me know if there's anymore more you want me to provide.

    Cheers!

    bug 
    opened by GideonWislang 7
  • Introduce WordPress VIP coding standards and fixes for existing errors

    Introduce WordPress VIP coding standards and fixes for existing errors

    See this ticket as a main reference and for discussions: https://github.com/wp-graphql/wp-graphql/issues/1535

    WordPress VIP has pretty high coding standards and everyone who will work with VIP in the future will face the same problems as our team right now. It would be great if we could get coding standards up and running with VIP's standards.

    Ideally we could setup PHP_Codesniffer with all the configurations of them and let a bot check run through it before merging PRs.

    We will attempt to setup everything and also fix major errors, so that we will be able to use WPGraphQL in the future. It would be great if some maintainers can share some of their attention on this, so we don't end up breaking stuff.

    Also this is obviously open for discussion, we would just use that PR for our purposes anyways, but would greatly appreciate if it would make it into the main repos best practices.

    References:

    • https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-vip/
    • https://github.com/Automattic/VIP-Coding-Standards/tree/master/WordPress-VIP-Go
    enhancement question Stale 
    opened by henrikwirth 7
  • Added more Yoast data to the Schema

    Added more Yoast data to the Schema

    Added the following Yoast data to the Schema:

    SEO - opengraphUrl, opengraphSiteName, opengraphPublishedTime, opengraphModifiedTime.

    SEOSchema - siteName, wordpressSiteName, siteUrl.

    opened by izzygld 7
  • [Bug] - All posts return same title/metaDesc

    [Bug] - All posts return same title/metaDesc

    Steps to repro:

    1. wordpress site with yoast 14.0.3
    2. install wordpress plugin wpgraphql 0.8.4
    3. install wordpress plugin wp-graphql-yoasy-seo 3.3.0
    4. using some graphql editor (eg GraphIQL) execute the following query:
    {
      posts(first: 10) {
        edges {
          node {
            id
            title
            seo {
              title
              metaDesc
              focuskw
              metaKeywords
              metaRobotsNoindex
              metaRobotsNofollow
              opengraphTitle
              opengraphDescription
              opengraphImage {
                altText
                sourceUrl
                srcSet
              }
              twitterTitle
              twitterDescription
              twitterImage {
                altText
                sourceUrl
                srcSet
            }
            }
          }
        }
      }
    }
    

    expected: Title and meta description reflect each individual post

    actual: Title and meta description match the most recently generated post

    bug Yoast 14 
    opened by shawngrona 6
  • Archive SEO enhancements

    Archive SEO enhancements

    This PR complementary of #85 makes the following improvements to the archive SEO data by using Yoast SEO surfaces.

    • Show encoded title instead of Yoast SEO variables.
    • Add the metaRobotsNofollow value even if it is not configurable from the Search Appearance to simplify integrations.
    • Return a string instead of a boolean for the metaRobotsNoindex and metaRobotsNofollow values to keep it consistent across individual nodes.

    While the API is well-documented for current pages, I didn't find a way to get the global values for individual pages. I'm also wondering if the archiveLink field should be renamed canonical.

    Before

    image

    After

    image

    opened by rodrigo-arias 7
  • Empty SEO fields when asPreview is true

    Empty SEO fields when asPreview is true

    Hello, I'm new to this plugin and WPGraphQL and I would like to know if it's correct that the fields are empty with asPreview or if I rather need to change something.

    This is my query:

    const GET_POST_BY_ID = gql`
    	query PostBySlug($id: ID!, $idType: PostIdType = URI, $asPreview: Boolean = false) {
    		post(id: $id, idType: $idType, asPreview: $asPreview) {
    			id
    			slug
    			isPreview
    			title(format: RENDERED)
    			content(format: RENDERED)
    			featuredImage {
    				node {
    					uri
    					altText
    				}
    			}
    		seo {
    			title
    			metaDesc
    			metaKeywords
    			breadcrumbs {
    				text
    				url
    			}
    		}
    		}
    	}
    `
    

    And this is the method I use to run the query:

    async function getSinglePost(id, asPreview = false) {
    	const idType = asPreview ? 'DATABASE_ID' : 'URI';
    	const { data } = await client.query({
    		query: GET_POST_BY_ID,
    		variables: {
    			id,
    			idType,
    			asPreview,
    		},
    	});
    	return data?.post || {};
    }
    

    When the variable asPreview is set to true, some fields related to Yoast SEO are empty. In particular:

    seo {
    	title
    	metaDesc
    	metaKeywords
    	breadcrumbs {
    		text
    		url
    	}
    }
    

    Am I wrong something or is it correct that it behaves like this?

    Needs investigation 
    opened by paolospag 0
  • Querying redirects using where params

    Querying redirects using where params

    There are cases that we need to query if there is a redirection set for a specific URI. For example, in case of "not found error" you may want to redirect the user to correct page instead of showing a 404 page.

    Currently, we can get all redirects from the SEO (Yoast config) node but it is not feasible to get a full list of redirects and filter on client side. It would be perfect if we can query the redirect with a where param, use the query result to redirect to correct page or to throw a 404 error.

    I would like to know your thoughts and possible development ideas on this.

    opened by evrenbal 0
  • Cannot return null for non-nullable field

    Cannot return null for non-nullable field "MediaItem.id"

    When running a query for twitterImage?.sourceUrl() I get the following error (when no image has been added to the Twitter preview/Twitter Image section in WordPress):

    [GQtyError: Internal server error] {
      graphQLErrors: [
        {
          debugMessage: 'Cannot return null for non-nullable field "MediaItem.id".',
          message: 'Internal server error',
          extensions: [Object],
          locations: [Array],
          path: [Array]
        }
      ]
    }
    

    Doesn't seem to be an issue with opengraphImage?.sourceUrl()

    opened by ttstauss 2
  • property=

    property="og:type" content="website" on Post

    Hello,

    Thanks for the great plugin. I am new to gatsbyjs and started my first project but can't able to solve the problem. I am getting "property="og:type" content="website"" on Post instead of "property="og:type" content="article".

    Apart from that, on the homepage no Yoast metadata showing in Gatsby

    Please help me

    Waiting for your reply.

    opened by techexpresslive 0
  • Cloudinary URLs

    Cloudinary URLs

    I posted this on the Cloudinary's WordPress Plugin repo as well. I wasn't sure which side could fix this.

    I know there are other issues already created for Cloudinary URLs populating correctly for WPGraphQL, but I think there's a subtle difference in what I'm facing (not pulling images from the content or raw HTML).

    I'm using the WPGraphQL Yoast SEO Addon to query SEO data from the Yoast general settings and individual Post/Page Yoast settings.

    When I set up a Facebook social image in the Yoast general settings, I get a WordPress-based URL instead of a Cloudinary URL.

    In addition to that, when I set the Facebook or Twitter images on a specific Post/Page, I get null for the opengraphImage result and a WordPress URL for the twitterImage result.

    opened by ttstauss 1
Releases(v4.20.0)
Owner
Ashley Hitchcock
Slinger of Divs, Slayer of JavaScript, hater of !important, survivor of IE6
Ashley Hitchcock
An WPGraphQL extension that adds SearchWP's query functionality to the GraphQL server

QL Search What is QL Search? An extension that integrates SearchWP into WPGraphQL. Quick Install Install & activate SearchWP v3.1.9+ Install & activat

Funkhaus 11 May 5, 2022
WPGraphQL Polylang Extension for WordPress

WPGraphQL Polylang Extension Extend WPGraphQL schema with language data from the Polylang plugin. Features For posts and terms (custom ones too!) Adds

Valu Digital 102 Dec 29, 2022
a wordpress plugin that improves wpgraphql usage together with wpml

WPGraphQL WPML Extension Contributors: rburgst Stable tag: 1.0.6 Tested up to: 5.6.1 Requires at least: 4.9 Requires PHP: 7.0 Requires WPGraphQL: 0.8.

null 42 Dec 15, 2022
Adds Settings to the Custom Post Type UI plugin to show Post Types in WPGraphQL

DEPRECATION NOTICE ?? Custom Post Type UI v1.9.0 introduced formal support for WPGraphQL!!! ?? With that, this plugin is being deprecated and will no

WPGraphQL 77 Aug 3, 2022
WordPress Plugin that Boost CTR. Improve SEO & Rankings. Supports most of the content type. Works perfectly with Google, Bing, Yahoo & Facebook.

WordPress Plugin that Boost CTR. Improve SEO & Rankings. Supports most of the content type. Works perfectly with Google, Bing, Yahoo & Facebook.

Brainstorm Force 109 Dec 19, 2022
Authentication for WPGraphQL using JWT (JSON Web Tokens)

WPGraphQL JWT Authentication This plugin extends the WPGraphQL plugin to provide authentication using JWT (JSON Web Tokens) JSON Web Tokens are an ope

WPGraphQL 268 Dec 31, 2022
Enable query locking for WPGraphQL by implementing persisted GraphQL queries.

?? WP GraphQL Lock This plugin enables query locking for WPGraphQL by implementing persisted GraphQL queries. Persisted GraphQL queries allow a GraphQ

Valu Digital 21 Oct 9, 2022
[ALPHA] Implementation of persisted queries for WPGraphQL

WPGraphQL Persisted Queries Persisted GraphQL queries allow a GraphQL client to optimistically send a hash of the query instead of the full query; if

Quartz 18 Jun 20, 2022
Send emails via mutation using WpGraphQl

WPGraphQL Send Email Plugin One of the simple things about a traditional WordPress sites is sending emails, this plugin makes it easy to do this via a

Ashley Hitchcock 18 Aug 21, 2022
Structured content blocks for WPGraphQL

WPGraphQL Content Blocks (Structured Content) This WPGraphQL plugin returns a WordPress post’s content as a shallow tree of blocks and allows for some

Quartz 72 Oct 3, 2022
WPGraphQL for Advanced Custom Fields

WPGraphQL for Advanced Custom Fields WPGraphQL for Advanced Custom Fields automatically exposes your ACF fields to the WPGraphQL Schema. Install and A

WPGraphQL 558 Jan 8, 2023
Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.

WpGraphQLCrb A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries. Important This is just the first version. There is a lot of work to be

Matheus Paiva 16 Aug 19, 2022
WPGraphQL FacetWP integration plguin

WPGraphQL-FacetWP: WPGraphQL provider for FacetWP Quick Install Download and install like any WordPress plugin. Documentation The WPGraphQL documentat

null 31 Dec 11, 2022
WPGraphQL for Meta Box

WPGraphQL-MetaBox: WPGraphQL provider for Meta Box Quick Install Download and install like any WordPress plugin. Documentation The WPGraphQL documenta

null 25 Aug 8, 2022
Add WooCommerce support and functionality to your WPGraphQL server

WPGraphQL WooCommerce (WooGraphQL) Docs • AxisTaylor • Join Slack Quick Install Install & activate WooCommerce Install & activate WPGraphQL Download t

WPGraphQL 546 Jan 2, 2023
The most powerful all in one, SEO-friendly theme for WordPress.

Help us Become a backer via Patreon. Make one time donation with PayPal. About Seven SERP Theme Seven SERP Theme is an open source WordPress theme. Wi

Seven SERP 3 Nov 19, 2021
This WordPress Plugin Boilerplate is meant for you to develop your own plugin on.

WordPress Plugin Boilerplate This plugin boilerplate is meant for you to develop your own plugin on. Support & collaboration Features OOP plugin core

richardev 2 May 10, 2022
This Plugin is used to install and activate multiple plugins in one go. I was facing problem uploading plugins one by one so I developed this to solve my problem. Hope you will enjoy using this plugin.

=== Bulk Plugin Installer === Contributors: jawadarshad Donate link: https://jawadarshad.io/ Tags: bulk plugin installer, import multiple plugins, up

Muhammad Jawad Arshad 2 Sep 20, 2022
🚀WordPress Plugin Boilerplate using modern web techs like TypeScript, SASS, and so on... on top of a local development environment with Docker and predefined GitLab CI for continous integration and deployment!

WP React Starter: WordPress React Boilerplate DEPRECATED: WP React Starter was a "research project" of devowl.io for the development of our WordPress

devowl.io GmbH 344 Jan 1, 2023