1

Ive picked up an old plugin and am needing to enhance it for my clients specific needs.

In the admin section there is a text area used to add info about a download (essentially a custom post type). However the description field is a simple text area, and so only text is stored. The client need to be able to use this in a similar fashion to the post or blog editor elsewhere in WP. Primarily it needs to add new lines and formatting without the need to manually add html.

So, from my limited knowledge of WP I'm assuming that the way forward is to some how tell WP to make this utilise the TinyMCE...

Here is the function used to create the in the relevant admin page;

    public function display_sdm_description_meta_box($post) {  // Description metabox
    _e('Add a description for this download item.', 'sdm_lang');
    echo '<br /><br />';

    $old_description = get_post_meta($post->ID, 'sdm_description', true);
    ?>
    <textarea id="sdm_description" name="sdm_description" style="width:60%;height:100px;"><?php echo $old_description; ?></textarea>
    <?php
    wp_nonce_field('sdm_description_box_nonce', 'sdm_description_box_nonce_check');
}

If someone could show me how to adapt this code to get the required result, I'd be really grateful.

Thanks in advance!

2

You need to use wp_editor()

$old_description = get_post_meta($post->ID, 'sdm_description', true); 
$editor_id = 'sdm_description';
$settings = array( 'media_buttons' => false );

wp_editor( $old_description , $editor_id, $settings );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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