2017-04-15 2 views
0

Ich habe ein benutzerdefiniertes Meta-Feld erstellt und ich möchte einen iframe-Link auf meine Beiträge speichern.Herstellung von Iframe mit Variable in WordPress

Wenn ich den Link von meinem Meta-Feld mit dem Code abrufen unter:

echo soundcloud_get_meta('soundcloud_soundcloud_shortcode'); 

Ich bekomme die ganze iframe als Text!

Aber wenn ich geben Sie den Link, wie in dem folgenden Code es

echo '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/151456970&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>'; 

arbeitet Ich denke, es zusätzliche Angebote auf dem ersten Beispiel legt und als Text erhalten. Wie kann ich das mit dem ersten Beispiel machen?

UPDATE

dies in meiner functions.php Datei ist

function soundcloud_add_meta_box() { 
    add_meta_box(
     'soundcloud-soundcloud', 
     __('SoundCloud', 'soundcloud'), 
     'soundcloud_html', 
     'post', 
     'normal', 
     'default' 
    ); 
} 
add_action('add_meta_boxes', 'soundcloud_add_meta_box'); 

function soundcloud_html($post) { 
    wp_nonce_field('_soundcloud_nonce', 'soundcloud_nonce'); ?> 

    <p>SoundCloud</p> 

    <p> 
     <label for="soundcloud_soundcloud_shortcode"><?php _e('SoundCloud Shortcode', 'soundcloud'); ?></label><br> 
     <input type="text" name="soundcloud_soundcloud_shortcode" id="soundcloud_soundcloud_shortcode" value="<?php echo soundcloud_get_meta('soundcloud_soundcloud_shortcode'); ?>"> 
    </p><?php 
} 

function soundcloud_save($post_id) { 
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; 
    if (! isset($_POST['soundcloud_nonce']) || ! wp_verify_nonce($_POST['soundcloud_nonce'], '_soundcloud_nonce')) return; 
    if (! current_user_can('edit_post', $post_id)) return; 

    if (isset($_POST['soundcloud_soundcloud_shortcode'])) 
     update_post_meta($post_id, 'soundcloud_soundcloud_shortcode', esc_attr($_POST['soundcloud_soundcloud_shortcode'])); 
} 
add_action('save_post', 'soundcloud_save'); 
+0

Können Sie mit ganzem Code Ihrer Funktion aktualisieren verwenden musste ? – patwoj98

+0

der Code von meiner functions.php hinzugefügt – Barlet

Antwort

0

ich html_entity_decode auf meiner Funktion zur Ausgabe als HTML

Verwandte Themen