0

I'm working on creating a custom content type but I'm having a bit of a problem formatting the create and edit views. I want to disable the main editor and focus only on the title, excerpt, and custom fields. I have the following jQuery code that will add the WYSIWYG to my custom fields, and that works fine:

<script type="text/javascript">
        /* <![CDATA[ */

        jQuery(document).ready( function () {
            if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
                tinyMCE.execCommand("mceAddControl", true, "solution_problem");
                tinyMCE.execCommand("mceAddControl", true, "solution_solution");
                tinyMCE.execCommand("mceAddControl", true, "solution_people");

            }
        });

        /* ]]> */
</script>

But then when I remove the editor from the 'supports' argument in *register_post_type*:

'supports' => array('title','thumbnail','excerpt'), 'taxonomies' => array('category', 'post_tag')

The default editor disappears but so do my custom WYSIWYGs. Anybody have any idea why this might be happening? Thanks!

2 Answers 2

1

I just had the exact same issue. You have to include the editor in the supports argument array to get custom mce boxes to show.

I solved the issue by hiding it with CSS:

function move_posteditor( $hook ) {
    if ( $hook == 'post.php' OR $hook == 'post-new.php' ) {             
        add_action( 'admin_print_footer_scripts', 'remove_edit_div' );
    }
}
add_action( 'admin_enqueue_scripts', 'move_posteditor', 10, 1 );

    function remove_edit_div() {
        global $post;
        $post_type=get_post_type( $post->ID );
            if ( ( $_GET[ 'post_type' ] ) == 'custom_pt_name'  || (  $post_type == 'custom_pt_name') ) {
            ?>


                <style>#postdivrich { display: none; }</style>

    <?php }
2
  • Hmmmm ... I think I see what you're trying to do there, but the code is returning a HTTP Error 500 I can't trace (replacing the OR in the second line didn't do the trick)
    – mcleodm3
    Commented Nov 3, 2011 at 19:40
  • Turns out that I can just add <style>#postdivrich { display: none; }</style> directly into the form and the editor is disappeared, no need for anything else. Thanks!
    – mcleodm3
    Commented Nov 3, 2011 at 20:13
0

You really don't even have to do that, if you just enqueue the correct tiny-mce js and css files, you should be fine on actually removing the editor from the post-type supports array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.