Shortcodes are available since WordPress 2.5.
What is a shortcode?
A shortcode is just a simple command for executing a script.
Every script has a name to identify it. The shortcode name of this plugin is youtube_sc.
WordPress parses and executes shortcodes automatically if you insert them into the default text editor of your posts/pages. All you have to do is insert (write) the shortcode into the text editor wherever you want its output to be.
Shortcodes accept parameters so that you can control the behaviour (result) of the script.
[youtube_sc url=ZUD3qUtT3go width=430]
In the shortcode above, I’m using 2 parameters: url and width
You can view the complete list of shortcode parameters this plugin accepts here.
Basic usage in a post/page editor
Insert the shortcode manually wherever you want into the text editor or use the editor’s Youtube button (1.7+) to generate and insert the shortcode for you.
[youtube_sc url=http://youtu.be/ZUD3qUtT3go]
The shortcode above outputs this video:
The url parameter (or any of its aliases like video or v) is the only one required in order to display a Youtube video. Its value is either a Youtube video URL or a Youtube video ID.
This plugin gives you a great bunch of parameters so you can customize the position, appearance and behaviour of each Youtube video.
To know more about available parameters please go to the Shortcode parameters page.
WordPress also allows us to execute shortcodes in template files.
Basic usage in a wordpress template file
<?php echo do_shortcode('[youtube_sc url=http://www.youtube.com/watch?v=ZUD3qUtT3go width=300 rel=0 fs=1]'); ?>This shortcode will embed a Youtube video of 300px wide with an automatically calculated height wherever you need in your site. It will disable related videos and enable the fullscreen button.
Recommended shortcode parameters for any Youtube video
[youtube_sc url=VIDEO_ID_OR_URL rel=0 fs=1 autohide=1 modestbranding=1]
Want to know more about shortcodes?
If you haven’t used shortcodes yet, please take some time and read these wordpress docs:
No matter what YouTube video I embed, this one is published!
http://www.youtube.com/watch?feature=player_embedded&v=QRS8MkLhQmM
Can you explain why?
The issue is you’re using a not supported value for the url parameter, I mean:
Instead of using this incorrect video url:
http://www.youtube.com/watch?feature=player_embedded&v=VIDEO_ID
You must use one of the supported values:
- http://www.youtube.com/watch?v=VIDEO_ID
- http://youtu.be/VIDEO_ID
- VIDEO_ID
That’s all, you were getting the default video on error.
I am getting the same situation. I have tried entering it using both the video code or the URL and get the same default player. Here is what I have entered:
[youtube_sc url=http://youtu.be/pHJiIweF8sQ]
or
[youtube_sc url=http://www.youtube.com/watch?v=pHJiIweF8sQ]
Both give me the default player. Any thoughts??????
Are you using version 1.8.3?
Sorry……feeling REALLY stupid now….I figured it out….I was putting it on the “Visual” instead of “HTML” section………wow……..sorry…….
YOU MADE A GREAT PLUGGIN DUDE!!!!!! it’s ALMOST idiot proof!
Ummm…it should work even if you enter the shortcode using the Visual tab. Sounds weird.
Is there a way to center these video objects without changing my theme css files?
You can do it adding this snippet to your functions.php file:
function center_youtube_videos() {
echo '<style type="text/css">.youtube_sc{margin:0 auto;}</style>';
}
add_action('wp_head', 'center_youtube_videos');
Cheers
Thanks,
just what I was looking for
I think I thanked you to soon. When I added the code to the function.php, it only centered it when I had teh code written like this ‘[youtube_sc url=URL width=450 rel=0 fs=1] – and it embedded a training video on entering subtitles onto youtube videos. When I added at the end of the code, that just showed up as text.
Please provide more details. I think you’re using it wrong.
Great Plugin, Thanks!
I always use the same dimensions and other options. I usually only change the Youtube address and Title.
Is there a way to save the options?
Hi Jack,
I’ll add that feature in version 1.9.
I’ll release version 1.9 somewhere between January and March.
Hi there – will this plug in work for my YouTube channel? I have a couple hundred video’s on my channel and I’d like to be able to have the user search for a video in my channel if possible. Way cool would be if every time my page loaded my latest video was up. Thanks.
This plugin allows you to embed customized YouTube videos, that’s its only mission.
It doesn’t provide a way to search for videos, sorry.
Nice website btw!!
Thank you for this plugin- very easy for my clients to understand!
I got this to put one youtube video on the above site. I don’t see any instructions.The two codex things I read but at the end at the end of the day to me (being nontech) they are dry jibberish.
The youtube is mine located in my channel for the public to view “Scotland google books” not a great title but more for SEO purposes. I am not after a sale from you.
I want a small code, instructions on where to put it and get the video up and running. I might put it on another site but that’s iffy at the moment.
Thanks,
Ronald
I will rework the “How to use” section :)
Pingback: Vademecum per l’inserimento di un video Youtube | StudentSASWeb
hello- great plugin! Is there a way to imbed a shortcode for a youtube channel that will automatically update the page as the videos are uploaded to youtube?
Thanks, unfortunately this plugin does not show videos from a channel but maybe there is one, check the plugins repository.
Good luck!
Hi there,
is there a way to have the embedded videos appearing one beside the other?
I would like to embed three videos let’s say in a WP page, but they all appear in a vertical order.
I al just typing the code like this without pressing enter at the end of each video: [youtube_sc url="http://www.youtube.com/watch?v=URdq6tL1Ag8" width="300"][youtube_sc url="http://www.youtube.com/watch?v=ljN7a1CKeoM&" width="300"][youtube_sc url="http://www.youtube.com/watch?v=vKuYrTO-HHc" width="300"]
Any idea on how to have them spread horizontally?
Thanks,
Edo
Sure, but it requires a bit of CSS.
Give each video a CSS class to float the videos to the left or right (that’s up to you) adding the
classparameter to the shortcodes (videos) that need it.Good luck!
thanks for the awesome plug in. I find when I embed a video, I have what looks like to be a table – thin narrow grey column to the left of the video. Don’t mean to spam but you’ll see it on this page www(dot)defqon1sydney(dot)com(dot)au
Really weird, review your CSS I guess. BTW, I tried to take a look at your website but instead all I can see is a wordpress login.
Hi there, the plugin works great. Is there a way to hide the block of text saying “Adobe Flash Player is required….”?
I tried visibility:none, though it seems like it removed the video post as well.
Thanks.
Hi Paul,
Why would you like to remove the message? It’s only shown when Flash is required to play a video and it’s not supported/installed. Youtube uses this technique too and shows the same message.
I am wanting to integrate this with the more fields plugin for WordPress. I have a field that users can paste their YouTube URL into and the template code that pulls this through to the page is .
How would I replace the URL in the below code to use whatever the users pastes into the field in edit mode?
So effectively, I think it should be something like:
<?php echo do_shortcode('[youtube_sc url=
rel=0]‘); ?>
But I’m not really familiar with PHP as you might have gathered.
Any help would be much appreciated.
< ?php echo do_shortcode('[youtube_sc url='. MORE FIELDS FUNCTION .'
rel=0]‘); ?>
Good day, is there anyway to move the display like 25px from the margin? I’m working with a theme that is padding the titles and body 25px from the left. How can I also do that to the youtube player in your plugin?
Use the class “youtube_sc” to target the videos.
Just installed the plugin and it the only way it works is in the HTML editor and only with this option [youtube_sc url=http://youtu.be/2YIAfatXtjo] if I add any other option it just shows a black window and in the Visual editor it wraps the url and options in “” and fails to show anything but the black window as mentioned above.
Any ideas? Thanks
(Latest WP and no other YT Plugins installed)