This code allows you to assign a specific Layout to Posts in “draft” mode only. Read inline comments as well, the thread is interesting too.
function assign_layout_by_post_status( $id, $layout ){ global $post; $preferred_layout = 5745; // my layout ID $control_layout = 0; //just set to 0 if you don't have any layout set for your post/product if( $id === $control_layout && $post->post_status === 'draft' && $post->post_type === 'product'){ return $preferred_layout; } return $id; } add_filter('get_layout_id_for_render', 'assign_layout_by_post_status', 10, 2);
Support Thread Example
Let us know if this snippet is not working for you:
This snippet doesn’t work