• Resolved Denis ?oljom

    (@dingo_d)


    I have a CPT called Events. I looked everywhere, but there doesn’t seem to be an option to assign event type structured data with my custom post type (https://developers.google.com/search/docs/data-types/event).

    All I can set in the Search Appearance is the Default Page Type (no events present).

    I also have a News CPT, and I can set the news to be Collection. But there is no Article type.
    I can add the article type using the wpseo_schema_article_post_type filter and hope this does the trick.

    Any advice on how to solve this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @dingo_d,

    For your News CPT, you can choose to either set the default page type using the Yoast schema settings or you can add custom code to use the filter.

    If you’re using the latest version of Yoast SEO, go to SEO > Search Appearance > Content Types. Under the News section, you can change the default schema setting from “WebPage” to “Article” for all News posts.

    We have more details about this feature in this guide: Selecting the Page or Article type in your Schema settings.

    Unfortunately, Yoast SEO doesn’t support adding the Event schema data, so we recommend looking in the WordPress plugin directory to find a plugin to add the required schema data for Events and display events on your site.

    Thread Starter Denis ?oljom

    (@dingo_d)

    Hi!

    I went to the Content types, but I only see the following page types:

    
    WebPage
    ItemPage
    AboutPage
    FAQPage
    QAPage
    ProfilePage
    ContactPage
    MedicalWebPage
    CollectionPage
    CheckoutPage
    RealEstateListing
    SearchResultsPage
    

    I cannot set it to an article, even after adding the filter

    
    // Add news to article structured schema.
    add_filter('wpseo_schema_article_post_type', 'my_site_add_additional_post_types');
    
    function my_site_add_additional_post_types($postTypesArray) {
    	$postTypesArray[] = 'news';
    
    	return $postTypesArray;
    }

    I don’t have any errors on the site otherwise, so not sure what could be the issue.

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    Since the CPT is a page, it shouldn’t support the Article schema, since it requires an author.

    You can learn more about it here — https://yoast.com/help/selecting-content-types-in-schema-settings/

    Note that some options may only be available on certain post types (e.g., Pages don’t support Article schema, because a valid Article requires an author).

    If you want to modify the schema output to your liking, you can refer to our Schema API documentation here — https://developer.yoast.com/features/schema/api

    Unfortunately, we can’t comment or provide further support if the custom data you’ve added is correct, as that is beyond our scope of support. Please do refer with your developer and the documentation on how to implement it properly.

    Thread Starter Denis ?oljom

    (@dingo_d)

    Thanks for the links, I’ll see what I can dig out ??

    Btw I am the developer that is implementing the fixes ??

    Plugin Support devnihil

    (@devnihil)

    @dingo_d You’re welcome, and please let us know if you require any further assistance in this matter.

    Plugin Support Jerlyn

    (@jerparx)

    Hi @dingo_d ,

    We’re closing this thread as there seem no further questions from you. Please feel free to open a new thread should you have further concerns.

    In case anyone else is struggling to get the wpseo_schema_article_post_types filter to output Article schema for their CPT, make sure you include author in the supports array when registering the post type.

    Thanks for posting, @dryan1144!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Enable custom structured data schema for custom post types’ is closed to new replies.