Shortcode supporting YouTube Search?
-
I love the widget feature where you can input a Search keyword or phrase to generate a playlist on the fly.
Can this be done with the [youtube] shortcode within a post or page?
-
You can indeed. Simply use a parameter of “search=yes” and then the search word should be specified instead of a video ID.
You’re awesome!
Is there a parameter for Playlist and User ID also?
There is! All the information is on here – https://ww.wp.xz.cn/plugins/youtube-embed/.
Awesome, I’ve played around with it. Is it correct that it doesn’t support normal youtube search operators like intitle:, quotation marks, and commas?
Quotes can be used to require a search phrase be present. Commas can let you specify filters after the search, like with regard to upload date, to only show videos from the recent week or month for example.
Or is your search code essentially putting quotes around the entire phrase inside?
It should support everything YouTube allows. You need to put quotes around the search term so that WordPress doesn’t think each word is a parameter of the plugin. However, this isn’t passed into the search to YouTube. You can use double or single quotes around your search term.
I’m not having any luck. Try this:
[youtube search=yes]baked salmon gordon ramsay[/youtube]
[youtube search=yes]”baked salmon” “gordon ramsay”[/youtube]
[youtube search=yes]intitle:”baked salmon” intitle:”gordon ramsay”[/youtube]
The 2nd and 3rd produce no results, even though entering them into youtube directly produces results.
Hmm, I see the issue here. The only way to pass a search parameter to YouTube is to place it in quotes, which are then conflicting with those within the search.
I’ll need to add this to a list of things I need to look at. Hopefully, I’ll find a fix for this.
When you write a fix, there are also other search operators like commas:
Gordon Ramsay Salmon, month, HD
That will give all HD videos in the last month.
Or
Presidential Debate, live
Kevin Hart, film
Wall Street Journal, channel
Joe Rogan, longHere are some articles:
https://www.gtricks.com/youtube/youtube-search-operators/
https://www.labnol.org/internet/youtube-search/19261/I don’t believe commas should cause problems – just quotes.
The commas do not perform the filtering that they do when entered directly on Youtube is what I’m saying. On Youtube, they call the secondary Filters as if you performed the search and then clicked FILTER and made some selections from the columns UPLOAD DATE, TYPE, DURATION, and FEATURES.
But when using commas with your shortcode, for example:
[youtube search=yes]gordon ramsay, today[/youtube]
It sends the word “today” as a search term, so it results in his appearances on the Today show, or put out by the channel called Today. In other words, it doesn’t filter by Upload Date. I’m just giving you this info so when you get around to working on your code, you will have all the necessary data to try to provide full functionality. Being able to call those filters from your short code, in addition to using quotes and the “intitle:” term, would make your plugin exponentially more powerful and more awesome!
Thanks!
The quotes and commas seem to work perfectly when I use your widget, just not the shortcode.
Actually sorry, the commas don’t work, but the quotes do.
That’s very odd – not what I’d expect. Okay, I’ll add this to the issues list and try and get it investigated as soon as I can.
The topic ‘Shortcode supporting YouTube Search?’ is closed to new replies.