{"id":15,"date":"2018-04-09T07:15:06","date_gmt":"2018-04-09T07:15:06","guid":{"rendered":"https:\/\/www.onlinenote.in\/wordpress\/?p=15"},"modified":"2018-04-09T07:15:06","modified_gmt":"2018-04-09T07:15:06","slug":"hide-page-visual-editor-if-certain-template-is-selected","status":"publish","type":"post","link":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/","title":{"rendered":"Hide page visual editor if certain template is selected"},"content":{"rendered":"<pre class=\"lang:default decode:true \">add_action( 'init', 'remove_editor_init' );\r\n\r\nfunction remove_editor_init() {\r\n    \/\/ If not in the admin, return.\r\n    if ( ! is_admin() ) {\r\n       return;\r\n    }\r\n\r\n    \/\/ Get the post ID on edit post with filter_input super global inspection.\r\n    $current_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );\r\n    \/\/ Get the post ID on update post with filter_input super global inspection.\r\n    $update_post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT );\r\n\r\n    \/\/ Check to see if the post ID is set, else return.\r\n    if ( isset( $current_post_id ) ) {\r\n       $post_id = absint( $current_post_id );\r\n    } else if ( isset( $update_post_id ) ) {\r\n       $post_id = absint( $update_post_id );\r\n    } else {\r\n       return;\r\n    }\r\n\r\n    \/\/ Don't do anything unless there is a post_id.\r\n    if ( isset( $post_id ) ) {\r\n       \/\/ Get the template of the current post.\r\n       $template_file = get_post_meta( $post_id, '_wp_page_template', true );\r\n\r\n       \/\/ Example of removing page editor for page-your-template.php template.\r\n       if (  'page-your-template.php' === $template_file ) {\r\n           remove_post_type_support( 'page', 'editor' );\r\n           \/\/ Other features can also be removed in addition to the editor. See: https:\/\/codex.wordpress.org\/Function_Reference\/remove_post_type_support.\r\n       }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>add_action( &#8216;init&#8217;, &#8216;remove_editor_init&#8217; ); function remove_editor_init() { \/\/ If not in the admin, return. if ( ! is_admin() ) { return; } \/\/ Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, &#8216;post&#8217;, FILTER_SANITIZE_NUMBER_INT ); \/\/ Get the post ID on update post with filter_input super global inspection. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hide page visual editor if certain template is selected - WordPress<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hide page visual editor if certain template is selected - WordPress\" \/>\n<meta property=\"og:description\" content=\"add_action( &#039;init&#039;, &#039;remove_editor_init&#039; ); function remove_editor_init() { \/\/ If not in the admin, return. if ( ! is_admin() ) { return; } \/\/ Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, &#039;post&#039;, FILTER_SANITIZE_NUMBER_INT ); \/\/ Get the post ID on update post with filter_input super global inspection. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/\" \/>\n<meta property=\"og:site_name\" content=\"WordPress\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-09T07:15:06+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/\",\"url\":\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/\",\"name\":\"Hide page visual editor if certain template is selected - WordPress\",\"isPartOf\":{\"@id\":\"https:\/\/www.onlinenote.in\/wordpress\/#website\"},\"datePublished\":\"2018-04-09T07:15:06+00:00\",\"dateModified\":\"2018-04-09T07:15:06+00:00\",\"author\":{\"@id\":\"\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.onlinenote.in\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hide page visual editor if certain template is selected\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.onlinenote.in\/wordpress\/#website\",\"url\":\"https:\/\/www.onlinenote.in\/wordpress\/\",\"name\":\"WordPress\",\"description\":\"Code Snippets\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.onlinenote.in\/wordpress\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hide page visual editor if certain template is selected - WordPress","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/","og_locale":"en_US","og_type":"article","og_title":"Hide page visual editor if certain template is selected - WordPress","og_description":"add_action( 'init', 'remove_editor_init' ); function remove_editor_init() { \/\/ If not in the admin, return. if ( ! is_admin() ) { return; } \/\/ Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT ); \/\/ Get the post ID on update post with filter_input super global inspection. [&hellip;]","og_url":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/","og_site_name":"WordPress","article_published_time":"2018-04-09T07:15:06+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/","url":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/","name":"Hide page visual editor if certain template is selected - WordPress","isPartOf":{"@id":"https:\/\/www.onlinenote.in\/wordpress\/#website"},"datePublished":"2018-04-09T07:15:06+00:00","dateModified":"2018-04-09T07:15:06+00:00","author":{"@id":""},"breadcrumb":{"@id":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.onlinenote.in\/wordpress\/hide-page-visual-editor-if-certain-template-is-selected\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.onlinenote.in\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Hide page visual editor if certain template is selected"}]},{"@type":"WebSite","@id":"https:\/\/www.onlinenote.in\/wordpress\/#website","url":"https:\/\/www.onlinenote.in\/wordpress\/","name":"WordPress","description":"Code Snippets","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.onlinenote.in\/wordpress\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":""}]}},"_links":{"self":[{"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":1,"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/posts\/15\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onlinenote.in\/wordpress\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}