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

Unexpected 404 after selecting Parent Page in Page Attributes for hierarchical CPT #16068

Open
4 of 9 tasks
bobbingwide opened this issue Sep 18, 2020 · 3 comments
Open
4 of 9 tasks

Comments

@bobbingwide
Copy link
Contributor

  • 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.

When selecting a parent page in the Page Attributes panel for a hierarchical Custom Post Type, a jQuery initiated REST request is sent to the server resulting in a 404. I believe the request is using pages instead of the Custom Post Type name.

https://s.b/cwiccer/wp-json/wp/v2/pages/1413

In this example the selected hierarchical post's ID was 1413.

This request appears to be coming from jQuery and is being invoked by WordPress SEO.
The request is not performed when WordPress SEO is deactivated.

image

Please describe what you expected to happen and why.

  • I don't expect a 404.
  • If any request is to be performed I expect it to be for the selected CPT.

How can we reproduce this behavior?

  1. Create a hierarchical Custom Post Type, e.g. hierarchical, which supports page-attributes.
  2. Create a hierarchical post called H1.
  3. Create a new hierarchical post called H1.1.
  4. Open the inspector and view the Network tab.
  5. In the Page Attributes panel choose H1 as the Parent Page.
  6. See the XHR request being fired off, the 404 response, and messages in the console.

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.1
  • Yoast SEO version: 14.9
  • Gutenberg: 9.0.0 - but problem occurs when activated or deactivated
  • Gutenberg plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:
  • Tested with theme: TwentyTwenty
@Djennez
Copy link
Member

Djennez commented Sep 18, 2020

Was able to reproduce. Looking at where / why this happens, it doesn't seem to affect much in terms of functionality.

For any developers looking to reproduce this, you can alter the Yoast Test Helper code (in src -> post-types.php) like this; replace private $movie_args with the following array (making it hierarchical):

		'label'        => 'Movies',
		'labels'       => [
			'name'          => 'Movies',
			'singular_name' => 'Movie',
			'add_new'       => 'Add New',
			'add_new_item'  => 'Add new movie',
		],
		'description'  => 'Our movies post type',
		'public'       => true,
		'menu_icon'    => 'dashicons-format-video',
		'has_archive'  => true,
		'hierarchical' => true,
		'rewrite'      => [
			'slug' => 'yoast-test-movies',
		],
		'show_in_rest' => true,
		'supports' => [
			'title', 'editor', 'author', 'thumbnail', 'page-attributes'
		],

Then, follow the reproduction steps as mentioned by @bobbingwide

@rmarcano
Copy link

rmarcano commented Jan 7, 2021

Please inform the customer of conversation # 684024 when this conversation has been closed.

@mayada-ibrahim
Copy link

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

No branches or pull requests

4 participants