add_shortcode('youtube', 'youtube_shortcode');
function youtube_shortcode($atts){
if(!isset($atts[0])) return;
$id = strip_tags($atts[0]);
ob_start();
?>
<div><a class="fancybox" href="#video_<?php echo $id; ?>">
<img src="http://img.youtube.com/vi/<?php echo $id; ?>/0.jpg" alt="Welcome To High Output" width="220px" height="120px" /></a></div>
<div id="video_<?php echo $id; ?>" style="display: none;">
<iframe title="YouTube video player" class="youtube-player" type="text/html" width="480" height="390" src="http://www.youtube.com/embed/<?php echo $id; ?>" frameborder="0"
allowFullScreen></iframe></div>
<?php
return ob_get_clean();
}
use it like: [youtube "dm36W5NTPag"]
Related Posts:
- WordPress plugin shortcode not working
- Get current post id witout passing in shortcode
- How do I create a Shortcode that returns text if domain is .com, not .co.uk
- Remove specific shortcode from get_the_content()
- Autoembeds don’t work with paragraphs
- How to Output HTML tags in do_shortcode?
- Nested Shortcode Detection
- Get all posts containing a shortcode
- How to display html in a shortcode
- Custom form, shortcode, and submit handler
- Videos via the video shortcode are always 640px wide?
- How to: How do I make my own shortcodes without plugins?
- Splitting Shortcode Attributes not working
- getting values from a shortcode with an include
- Create a shortcode in WordPress, again
- gutenberg widget outputting paragraph marks
- How to make shortcode output display where I choose
- Add Shortcode to a Div or Header [closed]
- Change link in get_terms if there is only one post in the category
- How to get total number of shortcodes in the wordpress application?
- How to change the page break numbering?
- WordPress display image link in shortcode
- Caption shortcodes not including caption as attribute
- stop shortcode stripping in category and archive pages
- Passing a nested shortcode as an argument of another shortcode?
- How does one insert a variable value into a “myCRED plugin shortcode [closed]
- Enumeration Contact form using database table’s numbe of rows [closed]
- Nested Code Snippets [closed]
- How do I display “Hello username” if logged-in on the homepage
- Adding a Cookie Session to Shortcode Content
- Gutenberg Block with Select from JSON-File
- Shortcode function executed twice?
- add widget to page content (using shortcode)
- Pagination for a page created by the shortcode “Product”
- Unable to the get the gallery inserted between shortcodes
- wp_editor in thickbox
- How to use the same shortcode with different attribute values on same page
- WordPress messes up with data attributes in shortcode output
- Displaying audio player as preview in audio post in WP3.6
- When are Shortcode Attributes Available in Template
- How to reload the shortcode content when the database is changing
- Best way to include reusable sections in page content
- Regenerating WordPress shortcodes based on value with AJAX
- Custom shortcode to display posts, first post is full
- Form shortcode with multiple options as attributes
- How to add data attributes to the wordpress audio shortcode
- Beginner’s question about shortcodes
- How to create a dropdown of shortcodes in edit mode for posts
- How to execute a shortcode outside the post content/entry in a theme?
- Multiple instances of the shortcode on the same page
- Shortcode from admin textarea to page
- Form processing: How to process form before output and access data from shortcode
- do_shortcode() won’t return PHP Array
- get data with shortcode
- Replace shortcode with output in database?
- Wrap php in shortcode
- Adding my own custom woocommerce shortcode to child theme, how?
- contact form 7 :create shortcode usable in email message [closed]
- Excerpt Length & List Category Posts Plugin
- Iteratively add sub shortcodes to php array
- Show shortcode only in posts
- How to execute a shortcode?
- Shortcode, Concatenating & Parse error: syntax error, unexpected T_FOREACH
- Better way to display multiple plugin output on the same page?
- Getting Shortcode Attributes befor content is displayed by the template
- How to remove double quotes in a shortcode?
- Shortcode to appear and show the date not code in Title and description of my website
- Colon is Missing In My Website Url in WordPress Shortcode
- Shortcode not working inside div html
- How to utilise multiple values from a single shortcode attribute?
- JavaScript missing from shortcode content
- How to test If a post has a particular term
- Multiple shortcodes with embedded JavaScript code in same page, how?
- Contact Form 7 shortcode is commented out, but I receive spam emails from it
- Multiple values for one variable
- How can I disable(remove) wpautop (wptexturize, convert_chars) for specific shortcodes only?
- How to load specific template page in a custom shortcode
- WordPress keeps automatically inserts
- shortcode is not rendered
- nested shortcodes from different plugins. too complex? [duplicate]
- Impossible to display modification in shortcode code?
- Contact form code not working. Need help!
- How to make shortcode enabled in JSON Feeds?
- How to add a shortcode to an HTML image tag
- Automatically add class-attribute to gallery?
- Shortcode works from functions.php but not from included file
- Why can’t I type [ ] opening and closing brackets on the Visual tab?
- Video Shortcode Only Returning a Link
- Loading shortcode stylesheet only when shortcode is in text widget [closed]
- Members only Passthrough
- How to add a nested shortcode into editor?
- load plugin with ajax [duplicate]
- Can not get shortcode content in function
- Enclosing shortcodes create line breaks
- Hook into existing shortcodes to manipulate the attributes?
- How can I hide the ACF shortcode when empty
- How to pass text input data to shortcode
- Using variable as shortcode parameter
- How to handle Ajax Calls, when using same shortcodes (with different parameters, e.g. ‘post-type’)?
- conditional shortcodes