{"id":6405,"date":"2016-02-08T15:02:54","date_gmt":"2016-02-08T20:02:54","guid":{"rendered":"https:\/\/themespress.ca\/?p=6405"},"modified":"2022-09-15T19:14:30","modified_gmt":"2022-09-15T23:14:30","slug":"wordpress-youtube-shortcode","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/wordpress-youtube-shortcode\/","title":{"rendered":"YouTube Shortcode for WordPress"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Shortcode are an easy to integrate content for WordPress users. Here&#8217;s a Youtube shortcode for WordPress.<\/p>\n<p>Here&#8217;s our Via Youtube shortcode. Simpy copy paste the code below inside your functions.php file.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-4703514\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-4703514\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">add_shortcode( &#039;via_youtube&#039;, &#039;via_you_tube_shortcode&#039; );\n\/\/ Nous creons la fonction \nfunction via_you_tube_shortcode($atts) {\n $atts = shortcode_atts( array(\n   &#039;id&#039;                 =&gt; &#039;&#039;,\n   &#039;width&#039;              =&gt; $width,\n   &#039;height&#039;             =&gt; $height,\n   ), $atts ); \/\/ Nous stockons les arguments \n   extract($atts); \/\/ Extraction des arguments ci dessus\n \n   \/\/ Nous retournons les resultats en iframe avec la hauteur et la largeur et l&#039;identifiant de la video qui sera present dans votre shortcode\n   return&#039;&lt;iframe src=&quot;https:\/\/www.youtube.com\/embed\/&#039;.$id.&#039;&quot; width=&quot;&#039;.$width.&#039;&quot; height=&quot;&#039;.$height.&#039;&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;allowfullscreen&quot;&gt;&lt;\/iframe&gt;&#039;; \n}<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Now go into the desired page and insert the shortcode below:<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-4376635\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-4376635\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">[via_youtube id=&quot;BJ-CmHZrKHU&quot; width=&quot;560&quot; height=&quot;315&quot;]<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Grab your video&#8217;s ID in the URL of your browser and use it to replace the ID used in the shortcode.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n\n\t<div  class=\"wpb_single_image wpb_content_element vc_align_left wpb_content_element\">\n\t\t\n\t\t<figure class=\"wpb_wrapper vc_figure\">\n\t\t\t<div class=\"vc_single_image-wrapper   vc_box_border_grey\"><img decoding=\"async\" width=\"415\" height=\"18\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2016\/02\/via-You-Tube1.png\" class=\"vc_single_image-img attachment-full\" alt=\"\" title=\"via-You-Tube1\" srcset=\"https:\/\/themespress.ca\/wp-content\/uploads\/2016\/02\/via-You-Tube1.png 415w, https:\/\/themespress.ca\/wp-content\/uploads\/2016\/02\/via-You-Tube1-300x13.png 300w\" sizes=\"(max-width: 415px) 100vw, 415px\" \/><\/div>\n\t\t<\/figure>\n\t<\/div>\n\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Youtube uses the following resolutions:<br \/>\n560 * 315<br \/>\n640 * 360<br \/>\n853 * 480<br \/>\n1280 * 720<\/p>\n<p>Also can be used with custom resolutions. Simply adjust the height and width parameter accordingly in the shortcode.<\/p>\n<p>With a few click, you&#8217;ll have your Youtube video displayed on any page.<br \/>\nHere&#8217;s another solution so your shortcode is displayed in your WordPress widget.<br \/>\nAdd the following line of code in your function.php file; make sure the code isn&#8217;t already there:<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-2718882\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-2718882\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">\/\/ Filtre permettant shortcodes visuels dans les widgets texte\nadd_filter(&#039;widget_text&#039;, &#039;do_shortcode&#039;);<\/pre><\/div><\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"Shortcode are an easy to integrate content for WordPress users. Here's a Youtube shortcode for WordPress. Here's our Via Youtube shortcode. Simpy copy paste the code below inside your functions.php<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/wordpress-youtube-shortcode\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4493,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[341],"class_list":["post-6405","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-social-medias"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/6405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=6405"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/6405\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4493"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=6405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=6405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=6405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}