1

So I've created a few meta boxes using the wp_editor, all are exactly as the following:

add_action( 'add_meta_boxes', 'business_facts_metabox' );              
function business_facts_metabox() 
    {   
        add_meta_box('business_facts', 'Business Facts', 'business_facts_output', 'page', 'normal', 'high');
    }

function business_facts_output( $post ) 
    {
    //so, dont ned to use esc_attr in front of get_post_meta
    $business_facts_value=  get_post_meta($_GET['post'], 'business_facts' , true ) ;
    wp_editor( htmlspecialchars_decode($business_facts_value), 'business-facts', $settings = array('textarea_name'=>'business-facts') );
    }


function save_business_facts( $post_id ) 
{                   
    if (!empty($_POST['business-facts']))
        {
        $data=htmlspecialchars($_POST['business-facts']);
        update_post_meta($post_id, 'business_facts', $data );
        }
}
add_action( 'save_post', 'save_business_facts' ); 

Unfortunately, when I output what is saved, it outputs everything, so it doesn't show bolds, instead if I were to output a bold word, it would output <strong>word</strong>, instead of word. I need it to output properly with styling and html working properly.

Is this possible using custom metaboxes? if so, what do I need to edit in my code?

1

So I figured this out almost immediately after posting this question (duh)

function business_facts_output( $post ) 
    {
    //so, dont ned to use esc_attr in front of get_post_meta
    $business_facts_value=  get_post_meta($_GET['post'], 'business_facts' , true ) ;
    wp_editor( htmlspecialchars_decode($business_facts_value), 'business-facts', $settings = array('textarea_name'=>'business-facts') );
}

Basically this bit here, where it says htmlspecialchars_decode($business_facts_value) needs to be changed. the htmlspecialchars_decode() function isn't needed here, instead I just needed the $business_facts_value

|improve this answer|||||

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.