Avoid losing post stickiness in the block editor
-
Thanks for the great plugin!
We’re using the block editor for our custom post type. Setting a post as sticky from Quick Edit works just fine for our use case. However, we’ve found that editing a sticky post in the block editor causes the stickiness to be lost.
The workaround I’ve implemented is this:
add_action( 'block_editor_meta_box_hidden_fields', function ( $post ) { echo '<input type="hidden" name="sticky" value="' . esc_attr( is_sticky( $post->ID ) ? 1 : 0 ) . '" />' . PHP_EOL; } );
The underlying problem is that the
edit_post()
function still fires when the block editor saves, and this logic unsticks the post unlesssticky
is present in$_POST
: https://cln.sh/ycV65n
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Avoid losing post stickiness in the block editor’ is closed to new replies.