wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

yoast_head_json missing fields in Rest API ( wp-json/wp/v2/ ) when conflicting slugs from CPT and CT

Open pkirk opened this issue 5 months ago • 9 comments

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

Please give us a description of what happened

To Reproduce

Step-by-step reproduction instructions

  1. Take a fresh WP
  2. Install a plugin like "CPT UI", create a CPT and a CT with the same slug: I created the CPT "test" and the CT "test" (this one linked to the Page PT); you can also use PHP code register_post_type() and register_taxonomy(), the problem doesn't depend on that plugin.
  3. Create a new entry with the new CPT
  4. Check che REST API https://www.example.com/wp-json/wp/v2/test/ , look at the "yoast_head_json" field, and you'll see that the 3.1 the "title" field is wrong, because it refers to the blog title instead of the CPT title 3.2 og_title, og_description, og_url, article_modified_time, og_image (if you have enabled the featured image with add_theme_support( 'post-thumbnails' ) ) and twitter_misc are missing; plus the "schema" field is wrong.

Expected results

  1. To have all the missing fields

Actual results

  1. They are missing

Screenshots, screen recording, code snippet

You can see the REST API's JSON differences here https://www.diffchecker.com/APAQik3J/ ( on the left the correct WP-JSON, with the CT disabled, on the right the wrong WP-JSON with the CT enabled )

Technical info

  • If relevant, which editor is affected (or editors):
  • [X] Block Editor
  • [X] Gutenberg Editor
  • (Block and Gutenberg seem to be the same, as per https://wordpress.org/documentation/article/wordpress-block-editor/ , why you list them both here? )
  • [ ] Elementor Editor
  • [ ] Classic Editor
  • [ ] Other:
  • Which browser is affected (or browsers):
  • [X] Every browser

Used versions

  • The problem is there with any device/operating system that I tested

pkirk avatar Jan 27 '24 13:01 pkirk