Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jeremy Frimond
Jeremy Frimond
14,470 Points

How to embed youtube video into a custom post type

I am trying to create a custom post type where each post will be a video from you tube.

I know on a standard post I enter the link into the content area and the video appears in the desired location on the site. When I create a custom post type with a content area and paste the youtube link all that shows up on the front end is the website link.

What code is needed to make a youtube video appear in a custom post type?

cheers

1 Answer

Does the content field you are using accept html? If it does, you could embed the video as an iframe:

<iframe width="560" height="315" src="//www.youtube.com/embed/gZa4yre0uEk" frameborder="0" allowfullscreen></iframe>

You could use this html above, and just replace "gZa4yre0uEk" with the id of the video you want (you can find the id in the url of the youtube video)

I hope the helps!