Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @tinismo

    Thanks for reaching out about your product schema. What you are referring to is unclear, and I can’t access your URL since it’s not publicly available.

    Have you changed the ?@type?of the?WebPage?piece into?ItemPage in WordPress > Yoast SEO > Settings > Content Types > Products > Schema?

    Thread Starter tinismo

    (@tinismo)

    Hello @maybellyne
    Here a public url : https://back.cluizel.com/wp-json/wp/v2/product/10798

    It should change the schema automatically from WebPage to ItemPage for singular product page based on this code from Yoast WooCommerce SEO plugin.

    /**
         * Changes the WebPage output to point to Product as the main entity.
         *
         * @param array $webpage_data Product Schema data.
         *
         * @return array Product Schema data.
         */
    public function filter_webpage($webpage_data)
    {
    if (is_product()) {
    if (!is_array($webpage_data['@type'])) {
    $webpage_data['@type'] = [$webpage_data['@type']];
    }
    $webpage_data['@type'][] = 'ItemPage';
    // We normally add a ReadAction on pages, we're replacing with a BuyAction on product pages.
    $webpage_data['potentialAction'] = [
    '@type' => 'BuyAction',
    'target' => YoastSEO()->meta->for_current_page()->canonical,
    ];
    unset($webpage_data['datePublished'], $webpage_data['dateModified']);
    }
    if (is_checkout() || is_checkout_pay_page()) {
    $webpage_data['@type'] = 'CheckoutPage';
    // We normally add a ReadAction on pages, adding that on a checkout makes no sense.
    unset($webpage_data['potentialAction']);
    }
    
    return $webpage_data;
    }
    • This reply was modified 1 year, 1 month ago by tinismo.
    Plugin Support Maybellyne

    (@maybellyne)

    If I understand correctly, you want to use the Yoast REST API to modify the structured data page type for your single products. However, the Yoast?Rest API?is read-only. Also, I cannot review the plugin code and why your customization doesn’t work. Since you mentioned using Yoast SEO WooCommerce, please contact the support team for that addon plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce SEO – Wrong schema for product via Rest API’ is closed to new replies.