Support » Plugin: Custom Post Type Sticky » 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 unless sticky is present in $_POST: https://cln.sh/ycV65n

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.