• Resolved telsenome

    (@telsenome)


    Hi Yoast,

    We wonder what query to run to fetch all cornerstone content in a specific category. So let’s say we have the category general and inside it there are 5 posts. 2 of them have been marked as cornerstone content in Yoast. Any idea on how to retrieve only these articles using the Rest API?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @telsenome

    While I am not sure whether available APIs will meet your specific requirement, Yoast SEO exposes several APIs designed to help advanced users, developers, and integrators access and manipulate our data and outputs.

    We have 3 kinds of API calls:
    – Our Rest API for accessing Yoast SEO metadata headlessly. Here, Yoast SEO includes a REST API which returns all of the SEO metadata (meta tags, schema.org data, and more) for any URL on a site. This makes it very easy for headless WordPress sites to use Yoast SEO to manage all of their SEO considerations.
    – Our Surfaces API, for returning information about (or properties of) a URL or post. In this way, we integrate Yoast SEO into your code
    – Our Metadata API, for adding or altering our meta tag outputs in the <head> of a document.

    Thread Starter telsenome

    (@telsenome)

    @suascat_wp, thank you. But let’s say I fetch an URL via the Rest API or Surfaces API. How would I determine if the URL has been set as cornerstone content or not?

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    Unfortunately, this is a bit technical and outside our scope of support. You may want to refer to this article from our developer documentation and see if it helps – https://developer.yoast.com/customization/yoast-seo/filters/cornerstone-post-types-filter/

    Thread Starter telsenome

    (@telsenome)

    @mikes41720 I see. Thank you for the link

    Sounds like maybe you’re looking for something like this:

    $args = array(
    ‘category_name’ => ‘general’,
    ‘meta_key’ => ‘_yoast_wpseo_is_cornerstone’,
    ‘meta_value’ => ‘1’
    );
    $query = new WP_Query( $args );

    Thread Starter telsenome

    (@telsenome)

    Thank you, that’s very helpful @trek7k. I’ll try it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fetching cornerstone content via the Rest API’ is closed to new replies.