Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save janneleppanen/9b733418c1152e690cdaf4a6b950b4e1 to your computer and use it in GitHub Desktop.

Select an option

Save janneleppanen/9b733418c1152e690cdaf4a6b950b4e1 to your computer and use it in GitHub Desktop.
Add Gutenberg editor to page_for_posts
/**
* Add editor support for posts page.
* If the posts page has content, the editor will turn to Gutenberg.
*
* @param object $post Post object.
* @return void
*/
function add_editor_for_posts_page( $post ) {
if ( ! isset( $post->ID ) || absint( $post->ID ) !== absint( get_option( 'page_for_posts' ) ) ) {
return;
}
add_post_type_support( 'page', 'editor' );
}
add_action( 'edit_form_after_title', 'add_editor_for_posts_page', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment