Yoast SEO Schema for Custom Post Type’s just doesn’t work right….

Recently I was tasked with enabling Schema for a client website which utilized Yoast SEO.

Initially it seemed like an easy request as Yoast SEO does support schema out of the box, however things weren’t quite as easy as I initially thought they would be.

Yoast SEO offers wide range of Schema confirguration options under the “Search Appearence” section of its options panel. Furthermore, it allows you to customize schema on a post by post basis too.

However, I found that when changing the schema for one of my post types to “NewsArticle” or “Article”, the posts were still loading with the “WebPage” schema type. No matter what settings I chose, Yoast SEO refused to use my schema settings for any custom post type.

I turned to the internet, hoping to find a solution but all I could find were some obscure references from the Yoast support team to the following page:

This page included mention of the following filter:


The only notation for this filter though is:

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

With little else to go on, I turned back to the internet and found some references from fellow users and developers:

Some useful information was included here, including a function to try and adjust the WebPage Schema to Article:

// 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 function did not get it working for me at all, even though it should have. In fact, a GitHub bug report was opened for this issue and one of the plugin developers suggested using code just like this:

As of February 26th 2021, this issue is still unresolved even though the ticket on Git itself has been closed. In the end, I ended up using the following code to disable Yoast Schema completely:

add_filter( 'wpseo_json_ld_output', '__return_false' );

I then manually coded schema into my clients theme. This may not be the easiest option for some, so I can also recommend “Schema & Structured Data for WP & AMP” from the WordPress Plugin Repository, which I have tested and appears to work very well!

Experiencing this bug too? Did you find a solution?

Let me know below!

Leave a Reply

Your email address will not be published. Required fields are marked *