• Resolved Shihab Malayil

    (@shihabmalayil)


    This is my custom meta box, here text area showing html tags.i used tinymc textaea editor. and i try to use wp_editor also. but data not saving.if it saved, i don’t know how to call it.
    please help me find solution

    
    add_action("admin_init", "admin_init");
    	add_action('save_post', 'save_points');
    	function admin_init(){
    	add_meta_box("productInfo-meta", "Product Details", "product_meta_options", "product", "normal", "low");}
    
    	function product_meta_options(){
    		global $post;
    		$custom = get_post_custom($post->ID);
    		$category = $custom["category"][0];
    		$brand = $custom["brand"][0];
    		$features = $custom["features"][0];
    		$holds = $custom["holds"][0];
    ?>
    <table>
    	<tr>
    		<td>Category</td>
    		<td> <input type="text" size="100" name="category" value="<?php echo $category; ?>" /> </td>
    	</tr>
    	<tr>
    		<td>Brand</td>
    		<td> <input type="text" size="100" name="brand" value="<?php echo $brand; ?>" /> </td>
    	</tr>
    	<tr>
    		<td>Features</td>
    		<td><textarea rows="20" cols="100" name="features"><?php echo $features; ?></textarea></td>
    	</tr>
    	<tr>
    		<td></td>
    		<td>
    		<?php wp_editor( $content, 'test_content', $settings = array('textarea_name'=>'test_content','textarea_rows'=>20) );?>
    		</td>
    	</tr>
    	<tr>
    		<td>Holds</td>
    		<td><textarea rows="20" cols="100" name="holds"><?php echo $holds; ?></textarea></td>
    	</tr>
    </table>
    
    <?php
    }
    
    function save_points(){
    	global $post;
    	update_post_meta($post->ID, "category", $_POST["category"]);
    	update_post_meta($post->ID, "brand", $_POST["brand"]);
    	update_post_meta($post->ID, "features", $_POST["features"]);
    	update_post_meta($post->ID, "holds", $_POST["holds"]);
    }?>
    
    
    

    -Thank You-

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    You save the editor content just as you would save any other textarea content, using the name passed in settings as the $_POST key. Note that editor ids and names must only be lowercase letters, no underscores or hyphens are permitted.

    Thread Starter Shihab Malayil

    (@shihabmalayil)

    Hi Bcworkz, Thankyou for your replay.

    
    function product_meta_options(){
    global $post;
    $extra = $custom["extra"][0];
    
    
    
    <?php wp_editor( $content, 'extra', $settings = array('textarea_name'=>'extra','textarea_rows'=>20) );?>
    
    
    
    function save_points(){
    global $post;
    update_post_meta($post->ID, "extra", $_POST["extra"]);
    
    

    data not saving and normally editor content caliing as the_content(); or the_excerpt();. Here, how can i print the content?.

    Thread Starter Shihab Malayil

    (@shihabmalayil)

    Hi bcworkz, i got the answer.but i don’t know how to print the code in my page. we can use
    if editor content like

     <?php the_content();?>

    if textarea custom field

    <?php echo esc_html( get_post_meta( get_the_ID(), 'holds', true ) ); ?>

    here how can i call in to my page ?.hop you can solve easily.
    Thankyou

    https://wordpress.stackexchange.com/questions/104786/wp-editor-not-saving-data-and-text-area-showing-html-tags

    Moderator bcworkz

    (@bcworkz)

    It depends on your theme and where you want the content to appear. You need to identify the correct theme template file that is outputting content where you want the custom field values to appear. It must also be inside “The Loop” which typically is formed with this code:

    <?php /* Outside the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php /* Inside the loop */ ?>
    <?php endwhile; ?>
    <?php /* Outside the Loop again*/ ?>

    Other than that, just place the code you have where you want it to appear in the “flow” of the content.

    Thread Starter Shihab Malayil

    (@shihabmalayil)

    Thank you BCWorkz

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_editor not saving data, and text area showing html tags.’ is closed to new replies.