• Resolved selenii

    (@selenii)


    I am trying to change the schema of the article piece, e.g. change Type to Event. But I don’t need this for all articles, I can only do it from the category “seminar”. Here is my approach:

    add_filter( ‘wpseo_schema_article’, ‘change_article_to_event_if_seminar_category’ );

    function change_article_to_event_if_seminar_category( $data ) {

    if ( has_category( ‘seminar’ ) ) {
    $data[‘@type’] = ‘Event’;
    }

    return $data;
    }

    Translated with DeepL.com (free version)

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

    (@maybellyne)

    Hello @selenii,

    Thanks for reaching out about your site’s structured data. Yoast SEO automatically describes your pages using?schema.org.?By default, Yoast SEO describes your?Pages?by using?WebPage?schema, and describes your?Posts?by using?Article?schema?(and?WebPage?schema). For most users, you won’t need to change these default settings (and?setting invalid options might result in errors).

    By overriding the defaults, you may alter your schema markup in ways that don’t make sense or that are incomplete. Unfortunately, we’re unable to review your code implementation as providing development support is outside the scope of our support.

    Thread Starter selenii

    (@selenii)

    That is exactly the reason. I would like to change the default “Article”. It works really well. Now I just want the change to only apply to specific posts from the specific category and its subcategory. Is my approach correct?

    Plugin Support Maybellyne

    (@maybellyne)

    We’re unable to check if your approach is correct as providing development support is outside the scope of our support.

    • This reply was modified 11 months, 1 week ago by Maybellyne.
    Plugin Support Jose Varghese

    (@josevarghese)

    This thread was marked resolved due to a lack of activity, but you’re always welcome to re-open the topic. Please read this post before opening a new request.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change schema type for specific category’ is closed to new replies.