Wordpress-seo: Cannot change default schema Article type for custom post type

Created on 15 Aug 2020  路  8Comments  路  Source: Yoast/wordpress-seo

  • [ ] I've read and understood the contribution guidelines.
  • [ ] I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

In #15532 support for the Web Stories plugin has been added. That integration uses the wpseo_schema_article_post_types filter as originally suggested by @jdevalk in #13446.

We have just noticed that this filter does nothing. It lives in \Yoast\WP\SEO\Helpers\Schema\Article_Helper::is_article_post_type() but that method is never used by Yoast SEO except for in deprecated code. So it seems like Article_Helper and the wpseo_schema_article_post_types should be deprecated too.

Please describe what you expected to happen and why.

Now, we are left wondering how we can ensure a default Article type for Web Stories. All I can see is this option in the settings:

Screenshot 2020-08-15 at 15 02 50

That works fine. But surely there must be a way to do the same via code? This way we could set Article as the default instead of None.

There is the wpseo_schema_article_type filter, but it does not pass $this->indexable->object_sub_type as context, so it's not really reliable.

How can we reproduce this behavior?

  1. Install Yoast SEO and the Web Stories plugin
  2. Publish a story
  3. View it on the frontend and see the missing Article schema data

Technical info


* If relevant, which editor is affected (or editors):
- [ ] Classic Editor
- [ ] Gutenberg
- [ ] Classic Editor plugin


* Which browser is affected (or browsers):
- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Other

Used versions

  • WordPress version: 5.5
  • Yoast SEO version: 14.8
  • Gutenberg plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:
  • Tested with theme:
WP SEO issue

All 8 comments

@swissspidy as far as I can see wpseo_schema_article_post_types is called in some deprecated functions, but in some live functions as well. I am also getting an Article schema on web stories (which is what you wanted to achieve, from what I understand). Debugging shows that a breakpoint in your filter_schema_article_post_types is hit as well.

Maybe it's going wrong here:

        if ( $this->context->site_represents === false ) {
            return false;
        }

Does your installation have a valid organization / person set in SEO -> Search Appearance -> bottom few options ?

@Djennez Interesting. When the breakpoint is hit, what's the stacktrace? Because it doesn't happen here.

Again, I don't see any occurrences of wpseo_schema_article_post_types in the code base outside the deprecated functions. Is it perhaps a dynamic filter?

I do have a valid organization set under SEO -> Search Appearance -> General.

Still, I don't get the Article schema for Web Stories unless I choose that option under SEO -> Search Appearance -> Content Types.

So it fails at this section:

if ( $this->context->schema_article_type !== 'None' ) {
    $this->context->main_schema_id = $this->context->canonical . Schema_IDs::ARTICLE_HASH;

    return true;
}

Welp, ok, my bad. I was testing this with 14.7 it seems. That version works as expected. The function call seems to have been removed in https://github.com/Yoast/wordpress-seo/commit/da9bcd7935f92a4bea9f1a951f48a3ecb4960c0e . And indeed, now it's only called in deprecated functions.

Tagging @jdevalk . Was this change intended and is the wrong filter being used now? Or did the above change "deprecate" the wpseo_schema_article_post_types filter by accident?

There is the wpseo_schema_article_type filter, but it does not pass $this->indexable->object_sub_type as context, so it's not really reliable.

I think this is the main thing we should fix. It's much less implicit than relying on wpseo_schema_article_post_types. Asking @herregroen to chip in here.

Created 2 internal bugs ( https://yoast.atlassian.net/browse/QAK-2182 & https://yoast.atlassian.net/browse/QAK-2183 ).

One is to bring back the filter that was essentially broken here. The other one is to ship context to the wpseo_schema_article_type filter.

Thanks! Would be great to see this land soon. I can also help test/update the Web Stories integration once those are fixed.

In the meantime, time to remove the wait for feedback label on this issue? :-)

This has been prioritized for 14.9, which is due to come out on September 1st

Closing because the above two PRs to fix yoast.atlassian.net/browse/QAK-2182 and yoast.atlassian.net/browse/QAK-2183 have been merged 馃帀

Was this page helpful?
0 / 5 - 0 ratings