Viewing 3 replies - 1 through 3 (of 3 total)
  • I needed this too.

    Install this as a separate plugin. I made it so that it hides the main content block of a page with the title “Home Page”, but you can change it to whatever title you need. There is a small link to re-enable the main content on the fly if needed.

    <?php
    /*
    Plugin Name: Hide Main Content Block
    */
    
    function init_hidemaincontent() {
    	add_meta_box('hide_content',__('Hide Main Content Block','cms'),'add_hidecontent_box','page','normal','high');
    }
    
    add_action('admin_init','init_hidemaincontent');
    
    function add_hidecontent_box() {
    	global $post;
    
        if ( esc_attr( htmlspecialchars( $post->post_title ) ) == 'Home Page') {
                echo "<style type=\"text/css\">#postdivrich{display:none;}</style>";
                echo "<script language=\"javascript\"> function toggle() {";
                echo "var ele = document.getElementById(\"postdivrich\"); var text = document.getElementById(\"displayText\");";
                echo "if(ele.style.display == \"block\") {ele.style.display = \"none\";text.innerHTML = \"show main content area\";}";
                echo "else {ele.style.display = \"block\"; text.innerHTML = \"hide main content area\";}}</script>";
                echo '<a id="displayText" href="javascript:toggle();">show main content area</a>';
            }
    }
    Thread Starter RobWatkins

    (@robwatkins)

    Brilliant, I’ll give it a go, ta!

    EDIT: Works perfectly, thanks.

    Hi rwparris!

    Any idea how to make the above code work in 3.2.1?

    I can’t seem to figure out which bit to change to make it work. (or maybe I’m missing something?)

    I get the “Hide Main Content Area” postbox with “show main content area” link inside, but the content editor is above it just like normal.

    Assuming 3.2 changed an admin parameter of some kind, but can’t find it.

    Thanks in advance! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Multiple content blocks] Hiding main content editor’ is closed to new replies.