hoducha / wp-markdown-editor

Markdown Editor for Wordpress
GNU General Public License v2.0
64 stars 15 forks source link

Selectively inject markdown editor based on supported post types. #12

Open vovafeldman opened 7 years ago

vovafeldman commented 7 years ago

We added the following code to the functions.php of our theme to only add the editor for docs CPT:

    function update_supported_markdown_posts() {
        add_post_type_support( 'docs', WPCom_Markdown::POST_TYPE_SUPPORT );

        remove_post_type_support( 'post', WPCom_Markdown::POST_TYPE_SUPPORT );
        remove_post_type_support( 'page', WPCom_Markdown::POST_TYPE_SUPPORT );
    }

    add_action( 'init', 'update_supported_markdown_posts', 9999 );

Without the code modifications, the editor is triggered in all posts and pages.