June 3, 2013 at 11:47 pm 4523
|Tareq Hasan||I created a URL field for a link to a YouTube Video. It displays the text of the link when I include this in the single.php ID, 'you_tube_link', true ); ?> How can I get to embed and auto display the video rather than just show the text of the link?|
June 4, 2013 at 12:51 am 4525
Check this page:
Maybe wrap it in shortcode to display? For example does this work, or something like it?
June 4, 2013 at 1:38 am 4526
Tried that and it prints out the following:
and on those that don’t have a YouTube link it prints out:
I checked out that WordPress Page plus about every other page about embedding a YouTube video in the single.php
It works if it is included in the Post Body but not as a field unto itself.
June 4, 2013 at 4:04 pm 4542
Then I’m unclear too — maybe try to make sure it’s wrapped in the Loop? I’d like to know how you finally find a solution~
June 5, 2013 at 10:52 am 4579
Create a custom field called youtubeid and on the input side only put the video id.
Then write a function to display the output, add this in your page template.
Place this in your template where you want the video to show.
June 5, 2013 at 11:11 am 4581
Because you are using wp userfrontend pro your function should be this.
June 5, 2013 at 11:14 am 4582
If you are going to make this function work for multiple youtube videos then put the function in your loop below
The each time you input a video id for individual posts it will show the id specific video on the post 🙂
June 5, 2013 at 1:20 pm 4584
For some reason – this did not work for me in my single.php – I did put it inside the loop.
If I include a YouTube link inside the “content” it works fine. I tried creating a textarea (with RichText turned off) and using that for the link, but it did not work – it just displayed the link url.
June 5, 2013 at 2:36 pm 4585
June 5, 2013 at 3:22 pm 4586
Works perfectly – thanks again!
June 5, 2013 at 3:57 pm 4587
Yes, seems to work well with oembed 🙂
July 5, 2013 at 3:16 pm 5617
sorry, I need to get this thing work,
this is what I append to my function.php
and this in my single.php
In the form I add a custom TEXT FIELD for the youtube id
Is it all right?
July 5, 2013 at 3:44 pm 5619
when you put
make sure your yourtube custom field meta key is – you_tube_link
does it makes sense ?
July 5, 2013 at 4:19 pm 5621
Sorry, I don’t think to follow, do you mean this:
I have this doubt, shall I create a new custom post type or is the plugin wp youtube lyte that makes all of it
July 6, 2013 at 5:59 pm 5636
You don’t need to create any function. Just make sure you have a full youtube video URL in that custom field and it should work.