ashhitch / wp-graphql-yoast-seo

This is an extension to the WPGraphQL plugin for Yoast SEO
GNU General Public License v3.0
216 stars 49 forks source link

Dynamic date SEO query #151

Open marcusforsberg opened 1 year ago

marcusforsberg commented 1 year ago

148 introduced the ability to query date archive settings, which works well.

However, is there any way to add a dynamic query for this where you can specify a specific date? In the Yoast Settings, you can add a "Date" variable which is normally replaced with the actual date. Being able to utilize that variable in GraphQL would be quite powerful.

Consider a date archive setup such as this:

Screen Shot 2023-02-16 at 4 43 56 PM

The query would return:

"seo": {
  "meta": {
    "date": {
      "description": "",
      "title": "Posts from: - my-site"
    }
  }
}

There's no way for the client to know where to inject the date since the "date" variable has been stripped away.

Would it be possible to implement a custom query type such as this (with month and day being optional)?


query GET_DATE_ARCHIVE_SEO {
  dateSeo(year: 2023, month: 2, day: 16) {
    description
        title
  }
}