Wordpress - Show Default Editor on Blog Page ( Administration Panel )

In WordPress 4.2 the editor was removed on whichever page was assigned to show Latest Posts for whatever reason. The following function below ( original solution found here by crgeary ) will re-add the editor and remove the notification:

You are currently editing the page that shows your latest posts.

Here's some information on the hooks used:

  • edit_form_after_title - Used to remove the above admin notice.
  • add_post_type_support - Used to give editor support back to the Latest Posts page.


if( ! function_exists( 'fix_no_editor_on_posts_page' ) ) {

    /**
     * Add the wp-editor back into WordPress after it was removed in 4.2.2.
     *
     * @param Object $post
     * @return void
     */
    function fix_no_editor_on_posts_page( $post ) {
        if( isset( $post ) && $post->ID != get_option('page_for_posts') ) {
            return;
        }

        remove_action( 'edit_form_after_title', '_wp_posts_page_notice' );
        add_post_type_support( 'page', 'editor' );
    }
    add_action( 'edit_form_after_title', 'fix_no_editor_on_posts_page', 0 );
 }

Edit for WordPress 4.9

As of WordPress 4.9.6 this fails to re-instate the editor. It looks as though the action edit_form_after_title isn't called soon enough. This modification, called on the earliest non-deprecated hook following the editor's removal in edit-form-advanced.php, seems to work OK.

Apart from the change of hook, there's a change to the number of parameters too.

if( ! function_exists( 'fix_no_editor_on_posts_page' ) ) {

    function fix_no_editor_on_posts_page( $post_type, $post ) {
        if( isset( $post ) && $post->ID != get_option('page_for_posts') ) {
            return;
        }

        remove_action( 'edit_form_after_title', '_wp_posts_page_notice' );
        add_post_type_support( 'page', 'editor' );
    }

    add_action( 'add_meta_boxes', 'fix_no_editor_on_posts_page', 0, 2 );

 }

It's been a while, but I came across this topic while looking for a way to enable gutenberg editor on the Blog Page. Didn't find any clue in google, so I dived into wordpress code and found the solution. Here is the code:

add_filter( 'replace_editor', 'enable_gutenberg_editor_for_blog_page', 10, 2 );
/**
 * Simulate non-empty content to enable Gutenberg editor
 *
 * @param bool    $replace Whether to replace the editor.
 * @param WP_Post $post    Post object.
 * @return bool
 */
function enable_gutenberg_editor_for_blog_page( $replace, $post ) {

    if ( ! $replace && absint( get_option( 'page_for_posts' ) ) === $post->ID && empty( $post->post_content ) ) {
        // This comment will be removed by Gutenberg since it won't parse into block.
        $post->post_content = '<!--non-empty-content-->';
    }

    return $replace;

}

I used 'replace_editor' filter just because it is the last filter/action used before the check if Gutenberg should load. This could be any earlier filter or action with current post object available.

WordPress checks for two things: if the current post ID is the same as page_for_posts option and if the content is empty, so in this filter we just add some fake content which will be removed by Gutenberg since it is random HTML comment.

Hope someone will find it useful :)