Custom general settings (textarea field) don’t output HTML correctly

Question

I add my custom fields in genearal settings page. One of them using WordPress Editor – there i insert my HTML content. I creeated it using simple snippet:

add_action( 'admin_init', 'register_settings_wpse_57647' );




function register_settings_wpse_57647() 
{
    register_setting( 
        'general', 
        'opisproduktyseop',
        'esc_html'
    );
    add_settings_section( 
        'site-guide', 
        'Publishing Guidelines', 
        '__return_false', 
        'general' 
    );
    add_settings_field( 
        'opisproduktyseop', 
        'Enter custom message', 
        'print_text_editor_wpse_57647', 
        'general', 
        'site-guide' 
    );
}  

function print_text_editor_wpse_57647() 
{
    $the_guides = html_entity_decode( get_option( 'opisproduktyseop' ) );
    echo wp_editor( 
        $the_guides, 
        'sitepublishingguidelines', 
        array( 'textarea_name' => 'opisproduktyseop' ) 
    );
}

enter image description here

The problem starts when i try display content from this field in my theme. HTML don’t works:

enter image description here

I display it using:

echo get_option( 'produktyseoopis' );

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/custom-general-settings-textarea-field-dont-output-html-correctly/">

Custom general settings (textarea field) don't output HTML correctly</a>
0
, Patryk Patryk 3 months 0 Answers 34 views 0

Leave an answer