WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 6 weeks ago

#46264 new defect (bug)

Page attributes 'ORDER' does not saving data for post-type 'post'.

Reported by: tanvirul Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

I used add_post_type_support() function to support 'page-attributes' for Menu Order at post-type 'post'.

<?php
function prefix_add_posts_order() {
        add_post_type_support( 'post', 'page-attributes' );
}
add_action( 'admin_init', 'prefix_add_posts_order' );

When I save the post after putting an integer value in the Order field then no value is saving on 'wp_posts' table 'menu_order' column and it does not also update on the editor page.

But when I switch to TinyMCE editor it's working fine.

Attachments (1)

46264.diff (1.0 KB) - added by felipeelia 5 months ago.

Download all attachments as: .zip

Change History (3)

@felipeelia
5 months ago

#1 @felipeelia
5 months ago

  • Keywords has-patch needs-unit-tests added; needs-patch removed

Hi @tanvirul and welcome to WordPress trac :)

You shouldn't hook your function to admin_init, but to init. Anyway, I was able to reproduce the problem you reported.

That seems to happen because, for posts, pages, and attachments, the JSON Schema generated by WP_REST_Posts_Controller::get_item_schema() is restricted by the $fixed_schemas variable. That said, the menu_order field is never exposed to the Rest API.

I've uploaded a patch that uses $fixed_schemas for default attributes, but still checks if those post types support other attributes. Perhaps we should remove $fixed_schemas at all, and always check this dynamically, but I guess it was there for a reason, so let's wait for somebody else input here.

Also, for the Tests suite, I think we should probably move/copy test_update_page_menu_order_* functions from WP_Test_REST_Pages_Controller to use them for all post types (custom or not). But, again, someone more experienced may have better input for this.

#2 @lordspace
6 weeks ago

menu_order doesn't seem to retain its value in Gutenberg.
WP v5.2.2

Note: See TracTickets for help on using tickets.