Mostly my clients would ask for a separate video url or audio url for audio / video post format, and I think it’s kind of make sense because then everything looks organised.
I have managed to do that, but in a weird way.
First I thought it’s pretty simple because all I need to do is create a text field for the video embed code. Wrong… WordPress won’t render the thing as video / audio, only showing the embed code as text. I think the embed code should be in ‘the_content’ for WordPress to be able to render it as video / audio with player.
So I changed the field from text to WYSIWYG editor and it worked. But then obviously the buttons and the field size of the WYSIWYG doesn’t look make any sense at all. It should be just a plain simple text input box, I thought.
Then I decided to try find other ways to make it work so I changed again the WYSIWYG to plain input text box. When I got back to the front-end, the video is still there! I did also a test by changing the embed code, and it still works! I got exactly what I want now, the plain text box field for the video embed code and the embed code is properly rendered as video player by WordPress.
Why this happened and will it be a reliable solution for the idea?
Or is there a right way to do this? I got what I want to achieve, but i think that’s not really the way to do this.
I’ve tried also other way using the_content filter but then it got all mixed up because wordpress sees everything as content, not separating the video from text content.
Thanks for getting back on this & glad to hear about the oembed field! 🙂
I think it’s one of those weird ‘why didn’t they do that’ missing small details of wordpress. While it has post-format capabilities, I don’t get why anyone never thought of it.
I just did a try again but still didn’t work. Even if I put ‘do_shortcode’ it will only become a link, and not embedding anything. So for now I’m using the_content filter solution and it seems ok.
Im looking forward to using acf 5, thanks for the awesome work!
Viewing 3 posts - 1 through 3 (of 3 total)
The topic ‘Creating a video/audio embed code field the right way’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users