post attributes order not working correctly
I set up the post attributes order with the code attached to be modified within the editor.
add_post_type_support('post', array('page-attributes'));
The post attributes section with the order field shows up but unfortunately does not save any values and does not show up the value set in the database.
Please find more information here: https://stackoverflow.com/questions/55433707/wordpress-post-custom-order-not-working-showing-up-but-not-saving
Same issue here, order is not saved on post edit screen from Gutenberg block. But after adding the Order column to the post list screen it does save when using Quick edit from post list screen.
Same issue here, order is not saved on post edit screen from Gutenberg block. But after adding the Order column to the post list screen it does save when using Quick edit from post list screen.
Thank you for the feedback! I used a small plugin to enable the order column in the post list screen, which works (in the post list screen and not the Gutenberg editor) as well. Do you have an easier solution for this? And unfortunately this is only a workaround but not a fix.
I'm also experiencing this issue.
I confirm this problem as well on a theme where I have activated page attributes on posts for a theme where I allow authors to custom order posts. Feature added:
// add menu order to posts
function bigpicture_posts_order() {
add_post_type_support( 'post', 'page-attributes' );
}
add_action( 'admin_init', 'bigpicture_posts_order' );
In 5.2.1 whenever I edit the Order attribute and save, it is reverted to 0. If I edit from the quick menu, the order is saved. When I activate the Classic editor, it behaves as expected, order values entered are saved.
This a clear indication that the Gutenberg editor is not saving the change.
I'm also experiencing the same issue.
I have same issue. Wordpress version 5.2.4
Hi @nikischin thank you for reporting this issue 👍 I'm not able to reproduce it on the last version of Gutenberg editor. I think the issue was solved meanwhile since many Gutenberg releases happened since WordPress: 5.2.4 the last version where the problem was reported by @nguyentrongbang. The problem should be fixed on the last release of the Gutenberg plugin and on the next release of WordPress. If the problem is persisting in a test site with the Gutenberg plugin please leave a comment so we can look further into the issue.
Hi @jorgefilipecosta, thank you for your feedback!
This still seems to be an issue in Wordpress 5.3.2 as the post order is displayed in the quick-edit menu in the post overview correct and in the post detail screen displayed as 0 no matter what's displayed in the overview (and database).
Please note that this is an issue for posts only, pages are not affected and therefore working correct.
With the Gutenberg Plugin I tested my site where I had post order properties to my Post types, and there is no behavior change. They appear correctly in the Posts view (quickview edits ok), but when loaded in the editor, the value for Post Order is 0. And effort to change is reverted to 0 when post saved.
My code for adding support to posts and for managing column sorting:
// --------- ordering boxes --------------------------------------------------------------
add_action( 'admin_init', 'dimension_posts_order' );
// add order to posts aka "front boxes"
function dimension_posts_order() {
add_post_type_support( 'post', 'page-attributes' );
}
// Sort posts in posts view by menu_order in ascending or descending order.
// h/t http://wordpress.stackexchange.com/questions/66455/how-to-change-order-of-posts-in-admin
add_action('manage_posts_custom_column', 'dimension_columns_show_columns');
// add post order to posts aka "front boxes"
function dimension_columns_show_columns($name) {
global $post;
switch ($name) {
case 'order':
$views = $post->menu_order;
echo $views;
break;
}
}
// organize the admin view; removed date / category, insert slide order columns
// h/t http://stackoverflow.com/questions/27602116/how-to-add-order-column-in-page-admin-wordpress
if (is_admin()){
add_action('pre_get_posts', 'custom_post_order');
}
function custom_post_order($query){
/*
Set post types.
_builtin => true returns WordPress default post types.
_builtin => false returns custom registered post types.
*/
$post_types = get_post_types(array('_builtin' => true), 'names');
/* The current post type. */
$post_type = $query->get('post_type');
/* Check post types. */
if(in_array($post_type, $post_types)){
/* Post Column: e.g. title */
if($query->get('orderby') == ''){
$query->set('orderby', 'menu_order');
}
/* Post Order: ASC / DESC */
if($query->get('order') == ''){
$query->set('order', 'ASC');
}
}
}
add_filter('manage_posts_columns', 'dimension_columns');
function dimension_columns($columns) {
$dimension_columns = array();
foreach( $columns as $key => $value) {
if ( $key != 'date' and $key != 'categories' ) $dimension_columns[$key] = $value;
if ( $key== 'title' ) {
$dimension_columns['order'] = ' Box Order';
}
}
return $dimension_columns;
}
That you for the additional information, I'm able to replicate the issue.
5.7.1, Same issue here, the order is not saving
This is still a bug 4 years later with WP 6.0.3!?
Yes it is, I use it on a few landing page themes (https://github.com/cogdog/wp-dimension and https://github.com/cogdog/wp-bigpicture) where posts are used to order content on the main page. I just checked my own site, and while the post order is displayed in the posts view, when I edit one the value is listed as 0, and it refuses to update changed value (it can be edited via Quick Edit).
Guess that shows how few people even use built in Post Order for Pages....
The cause of the problem is the same as for #19805.
The REST API schema doesn't support the menu_order field, and even though the editor is sending the data, it's ignored on the server side.
I've found a similar trac ticket for Core. So I'll close the issue, the schema needs to be updated in Core, and there's no action required from the editor.
The REST API schema for the posts - https://developer.wordpress.org/rest-api/reference/posts/#schema. The core trac ticket - https://core.trac.wordpress.org/ticket/46264.