USharing
开放博客

Modify specal post page [remove_post_type_support( ‘page’, ‘editor’ )]

add_action('init', 'my_remove_editor_from_post_type');
function my_remove_editor_from_post_type() {
  remove_post_type_support( 'page', 'editor' );
}



function tn_disable_visual_editor( $can ) {
global $post;
if ( 353 == $post->ID )
return false;
return $can;
}
add_filter( 'user_can_richedit', ' tn_disable_visual_editor ' );


function remove_editor() {
    if (isset($_GET['post'])) {
        $id = $_GET['post'];
        $template = get_post_meta($id, '_wp_page_template', true);
        switch ($template) {
            case 'template_01.php':
            case 'template_02.php':
            case 'template_03.php':
            case 'template_04.php':
            // the below removes 'editor' support for 'pages'
            // if you want to remove for posts or custom post types as well
            // add this line for posts:
            // remove_post_type_support('post', 'editor');
            // add this line for custom post types and replace 
            // custom-post-type-name with the name of post type:
            // remove_post_type_support('custom-post-type-name', 'editor');
            remove_post_type_support('page', 'editor');
            break;
            default :
            // Don't remove any other template.
            break;
        }
    }
}
add_action('init', 'remove_editor');


  function remove_editor() {
      if (isset($_GET['post'])) {
          $id = $_GET['post'];
          $template = get_post_meta($id, '_wp_page_template', true);
          switch ($template) {
              case 'page_landpage.php':
              remove_post_type_support('page', 'editor');
              break;
              default :
              break;
          }
      }
  }
  add_action('init', 'remove_editor');




function remove_editor() {
    if (isset($_GET['post'])) {
    $id = $_GET['post'];
        if ( 104 == $id ) {
            remove_post_type_support('page', 'editor');
        }

    }
}
add_action('init', 'remove_editor');


* how to get page tempalte name by code wordpress 

add_action('wp_head', 'show_template');
function show_template() {
    global $template;
    echo basename($template);
}

or just use it directly in template (I tend to echo in footer.php in HTML comment)


<?php global $template; echo basename($template); ?>

 

赞(0) 打赏
未经允许不得转载:USharing » Modify specal post page [remove_post_type_support( ‘page’, ‘editor’ )]

觉得文章有用就打赏一下文章作者

微信扫一扫打赏