WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using 2 extra TinyMCE editors on my pages to add extra textfiels in my theme pages. I now realize that the auto-embed feature is not supported on content delivered thought custom fields. So i need to tell WordPress to enable this on these two extra custom fields.

Here is an example of the back-end part included in my functions.php file:

    function monster_meta_options() {
    global $post;
    $custom = get_post_custom($post->ID);
    $monster_tiny_1 = (isset($custom['monster_tiny_1'][0]) ? $custom['monster_tiny_1'][0] : '');
    //Use nonce for verification
    wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );

    //TinyMCE field! :)
    $args = array('wpautop' => true, 'media_buttons' => true, 'quicktags' => true,'textarea_name' => 'monster_tiny_1');
    wp_editor( html_entity_decode($monster_tiny_1), 'lower-left', $args);   

This is an example of how i output my custom field on the front end. A custom page named om-monster.php

                        <div class="entry-content-left">
                            $custom_field = get_post_meta($post->ID, 'monster_tiny_1', true);
                            $monster_tiny_1 = (isset($custom_field) ? $custom_field : '');

                        if ($monster_tiny_1 != '') {

                            echo wpautop(html_entity_decode($monster_tiny_1));

                        } ?>
                    </div><!-- .entry-content-left -->

So how can i enable autoembed on the content written in the custom TinyMCE editor (should be the same as a normal text field).

share|improve this question
up vote 2 down vote accepted

You're probably best off using echo apply_filters( 'the_content', html_entity_decode( $monster_tiny_1 ) ); instead of echo wpautop(html_entity_decode($monster_tiny_1)); and similar, which will run the autoembed behavior.

share|improve this answer
Just tried it out myself, and Thank you! this works perfectly! – Ole Henrik Skogstrøm Mar 21 '12 at 18:31
however i needed to add the code html_entity_decode to the variable because i use esc_attr when i put the information into the database. This is my working code 'echo apply_filters( 'the_content', html_entity_decode($monster_tiny_1) );' – Ole Henrik Skogstrøm Mar 21 '12 at 18:33
esc_attr() is really meant as escaping for display in an HTML attribute. You should use something like wp_kses_post() for sanitizing before saving to the database. – helenhousandi Mar 22 '12 at 10:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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