How can I adjust the height in a Wysiwyg box

Asked

Viewed 236 times

2

I need to use Custom Post Types and learned how to do in this article. There is one however, this article does not teach how to insert Custom Post Types into Pages or how to leave the <textarea> in the Wysiwyg format. What I need:

  1. Let him the textearea in Wysiwyg and still determine the height size height. Example: 100px, I don’t want it big, because it will be written little thing, and are 3 text box.

  2. Remove the main Content, or better leave only the Custom Post Types, remove the textearea that Wordpress already comes by default.

functions.php code used to include Custom Post Types on Pages:

add_action("admin_init", "admin_init");

function admin_init(){
  add_meta_box("credits_meta", "Design & Build Credits", "credits_meta", "page", "normal", "low");
}

function credits_meta() {
  global $post;
  $custom = get_post_custom($post->ID);
  $designers = $custom["designers"][0];
  $developers = $custom["developers"][0];
  $producers = $custom["producers"][0];
  ?>
  <p><label>Designed By:</label><br />
  <textarea cols="50" rows="5" name="designers"><?php echo $designers; ?></textarea></p>
  <p><label>Built By:</label><br />
  <textarea cols="50" rows="5" name="developers"><?php echo $developers; ?></textarea></p>
  <p><label>Produced By:</label><br />
  <textarea cols="50" rows="5" name="producers"><?php echo $producers; ?></textarea></p>
  <?php
}

I even found the code to insert a text box in Wysiwyg, but how can I adjust the height?

$content = '';
$editor_id = 'mycustomeditor';
wp_editor( $content, $editor_id );

2 answers

1

The function wp_editor( $content, $editor_id, $settings = array() ) has a third parameter that has the setting you need, textarea_rows.

The default values are:

$settings = array(
    'wpautop' => true,                     // use wpautop?
    'media_buttons' => true,               // show insert/upload button(s)
    'textarea_name' => $editor_id,         // set the textarea name to something different, square brackets [] can be used here
    'textarea_rows' => 20,
    'tabindex' => '',
    'tabfocus_elements' => ':prev,:next',  // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE
    'editor_css' => '',                    // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped".
    'editor_class' => '',                  // add extra class(es) to the editor textarea
    'teeny' => false,                      // output the minimal editor config used in Press This
    'dfw' => false,                        // replace the default fullscreen with DFW (needs specific DOM elements and css)
    'tinymce' => true,                     // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
    'quicktags' => true                    // load Quicktags, can be used to pass settings directly to Quicktags using an array()
) );

0

I would recommend using the Advanced Custom Fields module, simplifies this process and works well.

With it you can create specific fields (as in your case, a testo field with Wysiwyg) and associate it with a type of content. The way of creating specific templates follows the standard of wordpress as single-{post-type}. php

link to the module http://www.advancedcustomfields.com/

  • Even if this link is a good suggestion, this reply will not be valid if one day the link ceases to work. So, and also because it’s important for the community to have content right here, you’d better respond with more complete answers. Can you elaborate more your answer? A summary of the content of the link would help a lot! Learn more on this item in our Community FAQ: Answers that only contain links are good?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.