wordpress-seo
wordpress-seo copied to clipboard
yoast_head_json missing fields in Rest API ( wp-json/wp/v2/ ) when conflicting slugs from CPT and CT
- [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
- Take a fresh WP
- 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.
- Create a new entry with the new CPT
- 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
- To have all the missing fields
Actual results
- 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