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&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&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');
Können Sie mit ganzem Code Ihrer Funktion aktualisieren verwenden musste ? – patwoj98
der Code von meiner functions.php hinzugefügt – Barlet