Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online... and hereand here...and also hereand also here...looking for answers, but I don't know how to piece them together properly to fit with what I've already done.

Here's what I have...

add_action("admin_init", "tf_book_deets_create");

function tf_book_deets_create(){
    
    add_meta_box('tf_book_details', 'Book Details', 'tf_book_details', 'books');
}

function tf_book_details () {
    global $post;
    
    $custom = get_post_custom($post->ID);
    
    $tf_book_media = $custom["tf_book_media"][0];
    $tf_book_review = $custom["tf_book_review"][0];
    
    ?>
    
    <div class="admin_meta"> 
    <ul>
    
    <li><label>Reviews:</label><textarea rows="5" cols="70" name="tf_book_review" value="<?php echo $tf_book_review; ?>" ></textarea></li>
    
    <li><label>Media:</label><textarea rows="5" cols="70" name="tf_book_media" value="<?php echo $tf_book_media; ?>" ></textarea></li>
    </ul>
    
    </div>
    

<?php }

    add_action ('save_post', 'save_tf_book_details');   
    
    function save_tf_book_details(){ 
    global $post;
        
        update_post_meta($post->ID, "tf_book_media", $_POST["tf_book_media"]);
        update_post_meta($post->ID, "tf_book_review", $_POST["tf_book_review"]);
    
    }

I'm just looking for some ideas.

Thank You!

Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online... and here...and also here...looking for answers, but I don't know how to piece them together properly to fit with what I've already done.

Here's what I have...

add_action("admin_init", "tf_book_deets_create");

function tf_book_deets_create(){
    
    add_meta_box('tf_book_details', 'Book Details', 'tf_book_details', 'books');
}

function tf_book_details () {
    global $post;
    
    $custom = get_post_custom($post->ID);
    
    $tf_book_media = $custom["tf_book_media"][0];
    $tf_book_review = $custom["tf_book_review"][0];
    
    ?>
    
    <div class="admin_meta"> 
    <ul>
    
    <li><label>Reviews:</label><textarea rows="5" cols="70" name="tf_book_review" value="<?php echo $tf_book_review; ?>" ></textarea></li>
    
    <li><label>Media:</label><textarea rows="5" cols="70" name="tf_book_media" value="<?php echo $tf_book_media; ?>" ></textarea></li>
    </ul>
    
    </div>
    

<?php }

    add_action ('save_post', 'save_tf_book_details');   
    
    function save_tf_book_details(){ 
    global $post;
        
        update_post_meta($post->ID, "tf_book_media", $_POST["tf_book_media"]);
        update_post_meta($post->ID, "tf_book_review", $_POST["tf_book_review"]);
    
    }

I'm just looking for some ideas.

Thank You!

Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online... and here...and also here...looking for answers, but I don't know how to piece them together properly to fit with what I've already done.

Here's what I have...

add_action("admin_init", "tf_book_deets_create");

function tf_book_deets_create(){
    
    add_meta_box('tf_book_details', 'Book Details', 'tf_book_details', 'books');
}

function tf_book_details () {
    global $post;
    
    $custom = get_post_custom($post->ID);
    
    $tf_book_media = $custom["tf_book_media"][0];
    $tf_book_review = $custom["tf_book_review"][0];
    
    ?>
    
    <div class="admin_meta"> 
    <ul>
    
    <li><label>Reviews:</label><textarea rows="5" cols="70" name="tf_book_review" value="<?php echo $tf_book_review; ?>" ></textarea></li>
    
    <li><label>Media:</label><textarea rows="5" cols="70" name="tf_book_media" value="<?php echo $tf_book_media; ?>" ></textarea></li>
    </ul>
    
    </div>
    

<?php }

    add_action ('save_post', 'save_tf_book_details');   
    
    function save_tf_book_details(){ 
    global $post;
        
        update_post_meta($post->ID, "tf_book_media", $_POST["tf_book_media"]);
        update_post_meta($post->ID, "tf_book_review", $_POST["tf_book_review"]);
    
    }

I'm just looking for some ideas.

Thank You!

Source Link
Nadine
  • 377
  • 2
  • 8
  • 19

How to stop wordpress from mangling HTML in a metabox textarea

Can anyone lend a hand and suggest the best way to get a textarea in a meta box to stop mangling HTML? I've been digging around here online... and here...and also here...looking for answers, but I don't know how to piece them together properly to fit with what I've already done.

Here's what I have...

add_action("admin_init", "tf_book_deets_create");

function tf_book_deets_create(){
    
    add_meta_box('tf_book_details', 'Book Details', 'tf_book_details', 'books');
}

function tf_book_details () {
    global $post;
    
    $custom = get_post_custom($post->ID);
    
    $tf_book_media = $custom["tf_book_media"][0];
    $tf_book_review = $custom["tf_book_review"][0];
    
    ?>
    
    <div class="admin_meta"> 
    <ul>
    
    <li><label>Reviews:</label><textarea rows="5" cols="70" name="tf_book_review" value="<?php echo $tf_book_review; ?>" ></textarea></li>
    
    <li><label>Media:</label><textarea rows="5" cols="70" name="tf_book_media" value="<?php echo $tf_book_media; ?>" ></textarea></li>
    </ul>
    
    </div>
    

<?php }

    add_action ('save_post', 'save_tf_book_details');   
    
    function save_tf_book_details(){ 
    global $post;
        
        update_post_meta($post->ID, "tf_book_media", $_POST["tf_book_media"]);
        update_post_meta($post->ID, "tf_book_review", $_POST["tf_book_review"]);
    
    }

I'm just looking for some ideas.

Thank You!