• Resolved Jim Reekes

    (@reekes)


    I use a custom post for technical articles. They have all the needed data to qualify as a schema type “article.”

    Yoast is defaulting to WebPage, but I want it as Article. Blog posts are output as Article, and Pages are output as WebPage. It seems custom posts are output as WebPage as well.

    There must be a simple filter for me to make Yoast output my custom posts as Article. How?

    There’s only this incomplete mention of wpseo_schema_article_post_type

    wpseo_schema_article_post_type – allows changing for which post types we output the Article graph piece.

    https://developer.yoast.com/features/schema/api/

    How do you use this filter?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Jim Reekes

    (@reekes)

    Looking into the source code, I think I have figured out how to create the filter.

    Please verify this code is correct. If not, please provide the correct code. And please update the documentation to describe this filter option.

    // use schema type article
    function schema_article_post_types($post_types) {
    	$post_types = array('my-post-type', 'my-other-post-type', 'post');
    	return $post_types;
    }
    add_filter( 'wpseo_schema_article_post_types', 'schema_article_post_types' );
    • This reply was modified 5 years, 2 months ago by Jim Reekes.
    Plugin Support amboutwe

    (@amboutwe)

    You or your developer can modify the code to fit your needs. Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes.

    We recommend checking out Code Poet, WordPress Jobs, or WordPress Professional Network for development & consultancy.

    Thread Starter Jim Reekes

    (@reekes)

    Wow, I’m not asking for advice – I’m asking for documentation about your product. The Yoast docs are incomplete. They mention using the schema_article_post_types hook but DO NOT explain how to do so. All of your other hooks/filters explain this. Not this one. I’m only asking for documentation on how to use the hook you are recommending we use.

    I agree with the above, please could Yoast explain how to use the filter ‘wpseo_schema_article_post_type’. It is not clear what the code should look like – or even where it should be placed – for this to work.
    I am looking to change the og:type content from article to recipe as Pinterest is now reading my recipes as article rich pins, instead of recipe rich pins. Please provide clarification.

    I am experiencing the same issue. I’ve added the filter in my plugin that adds a custom post type for recipes but it does nothing instead of extending the places were the Article schema should occur.

    Please dear yoast team, give us some more documentation.

    Must have been the late time here in Germany…

    after deactivating and activating Yoast SEO it worked as intended.
    This is my code which is placed on the single custom post type template file:

    
    add_filter( 'wpseo_schema_article_post_types', 'nh_add_wpseo_article_schema_to_cpt');
    /**
     * Add Yoast SEO article schema for a custom post type.
     *
     * @author Norman H?hne
     */
    function nh_add_wpseo_article_schema_to_cpt( $post_types ) {
    
    	$post_types[] = 'your-cpt-slug';
    
    	return $post_types;
    }
    

    Hope that helps everybody out and that the yoast team is extending its documentation of the Schema API.

    • This reply was modified 4 years, 10 months ago by Norman H?hne.
    • This reply was modified 4 years, 10 months ago by Norman H?hne.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change schema type from WebPage to Article’ is closed to new replies.