Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yoast REST-API in yoast_head missing field thumbnailUrl, image #19049

Open
7 tasks
mgdev2022 opened this issue Oct 12, 2022 · 6 comments · May be fixed by #19093
Open
7 tasks

Yoast REST-API in yoast_head missing field thumbnailUrl, image #19049

mgdev2022 opened this issue Oct 12, 2022 · 6 comments · May be fixed by #19093

Comments

@mgdev2022
Copy link

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

In the rest-api => wp-json/wp/v2/posts/

in the JSON Attribute yoast_head the fields image and thumbnailsUrl are missing.

How can we reproduce this behavior?

  1. open a url like /wp-json/wp/v2/posts/
  2. search for thumbnailsUrl in the field yoast_head field in the value

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: 6.0.2

  • Yoast SEO version: 19.8

  • Relevant plugins in case of a bug:

  • Tested with theme: Newspaper HD, Twenty Twenty-Two
@mgdev2022 mgdev2022 changed the title Yoast REST-API head yoast_head missing field thumbnailURL, image Yoast REST-API in yoast_head missing field thumbnailURL, image Oct 12, 2022
@mgdev2022
Copy link
Author

	/**
	 * Gets the main image ID.
	 *
	 * @return int|null The main image ID.
	 */
	public function generate_main_image_id() {
		switch ( true ) {
			case \is_singular():
				return $this->get_singular_post_image( $this->id );
			case \is_author():
			case \is_tax():
			case \is_tag():
			case \is_category():
			case \is_search():
			case \is_date():
			case \is_post_type_archive():
				if ( ! empty( $GLOBALS['wp_query']->posts ) ) {
					return $this->get_singular_post_image( $GLOBALS['wp_query']->posts[0]->ID );
				}
				return null;
			default:
				return null;
		}

Maybe the error is in this function, because of return null in default?

@mgdev2022 mgdev2022 changed the title Yoast REST-API in yoast_head missing field thumbnailURL, image Yoast REST-API in yoast_head missing field thumbnailUrl, image Oct 12, 2022
@mmikhan
Copy link
Member

mmikhan commented Oct 14, 2022

I wonder why you want to show thumbnailUrl and image under the yoast_head in the Rest API? Those data aren't Yoast SEO but are part of the default WordPress Rest properties.

@webw4tcher
Copy link

In version 19.2 the fields were there. In the current version, these fields are gone. If you adjust the code below, the fields reappear but are then duplicated. So it seems a bug. Please restore the state of version 19.2. Thanks for the bug fix.

@mgdev2022 mgdev2022 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2022
@mgdev2022
Copy link
Author

I wonder why you want to show thumbnailUrl and image under the yoast_head in the Rest API? Those data aren't Yoast SEO but are part of the default WordPress Rest properties.

The problem did not occur in older versions and appears to be in the meta-tags-context.php file.

@mgdev2022 mgdev2022 reopened this Oct 17, 2022
@mmikhan
Copy link
Member

mmikhan commented Oct 24, 2022

Thanks for clarifying and clearing up the confusion. I investigated it further, and it turned out the thumbnailUrl you're referring to is part of the schema markup. The thumbnailUrl indeed appears in the Rest API under the yoast_head in Yoast SEO v19.3 or earlier but not since v19.4. Interestingly, the thumbnailUrl does appear in the schema markup outputting in the page source code in the latest release.

So, it seems to be a bug, but I have reached out for a confirmation internally before giving you a confirmation here. I'll get back to you on this once I have more information about it. In the meantime, I will mark the issue as a bug!

@mmikhan
Copy link
Member

mmikhan commented Oct 25, 2022

Thanks for your continued patience. It turned out to be a bug that most likely occurred here #18599. We moved the issue to our internal issue management repository (IM-2045) to have a fix ready for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants