On my page, I have many fields text area fields containing text, and one WYSIWYG field containing a YouTube video (I need it to be WYSIWYG because otherwise only the URL of the video would show, not the video itself).

Problem: my text area fields have no tags other than br tags in them, whereas my WYSIWYG is full of p tags, creating layout misalignments.

If I remove p tags from the WYSIWYG field containing the video (using $strip = array(‘

‘,’

‘); echo str_replace($strip,”,$field);), then the iframe of the video becomes invisible, meaning it’s there but it’s gray in Firebug and doesn’t show on the page.

Any suggestions?

2 Answers
2

You can try using wp_oembed_get and a textfield. You add the youtube url in the textfield.

Assuming the field name is youtube_url, your code will be something like:

if( get_field('youtube_url') ){
  $embed_code = wp_oembed_get( get_field('youtube_url') );
  echo $embed_code;
}

Leave a Reply

Your email address will not be published. Required fields are marked *