This is how I bootstrapped youtube embeds in one of my projects.
/**
* Responsive Youtube embeds.
*/
add_filter( 'embed_oembed_html', function( $html, $url, $attr, $post_ID ) {
if ( false !== stripos( $html, '<iframe ' ) && false !== stripos( $html, '.youtube.com/embed' ) ) {
$html = sprintf('<div class="embed-responsive embed-responsive-16by9">%s</div>', $html );
}
return $html;
}, 10, 4);
Please note this snippet is using anonymous functions which are available in > PHP 5.3
Related Posts:
- Get old values for post before saving new ones
- How to publish a post with empty title and empty content?
- How to change post status from publish to draft using hook in wordpress?
- Filter post before *editing*
- How can i do something after head like adding a hook for after head but before post
- Action hook for new pending posts?
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Ajax posts filter by date, comments, top views, top likes
- What is the filter or hook to add admin controls to posts on the front end?
- Change post order random through out the entire WordPress
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Trying to alter the post_content through the_post
- Modify posts listing at back end
- Hook for changing excerpt content when excerpt not set
- Is it possible to add a shortcode below post title?
- Restricting displayed posts to posts from only select authors
- How to add a custom class attribute into code wrapper? [duplicate]
- How to get the postID inside ‘content_save_pre’? Other hook?
- fire action when post is being edited as well as saved?
- save_post not working
- Filters do not work when there are multiple (one works)
- Issues with title-tag and document_title_parts
- How to detect single.php (but not single-portfolio.php)?
- Removing filter dropdown in posts table (in this case Yoast SEO)
- Execute function when post is published
- how to limit edit_form_after_title hook to page and post edit only?
- disable WP automatically inserted line breaks after an image
- How does filter the_posts work?
- Getting the post_id in wp_ajax function
- delete post also attachments
- How to call function within a page/post, to dynamically generate content?
- Restrict users from editing post based on the age of the post
- Count singular post views automatically
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Force update all posts in custom post type, no content changes
- Disable REST API for a user ROLE
- Add confirmation popup on “Move to Trash”
- How to filter content post only on save
- How can I list random authors from current post category?
- Disable single post page
- How to generate numbers indistinguishable for the IDs of the posts
- Getting current post ID in functions.php
- How to filter posts that belong to a specific category only if that is the only category
- get_current_screen() return null
- Register post status, exclude from searches
- Modify Image Source With The_Content Filter?
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Load post attached images on a single page site with fancybox
- Which WordPress hook fires after post content loaded?
- Setting posts_per_page for taxonomy term template
- How to filter, restrict and return posts based on custom user meta information
- Add filter by custom field to block of posts
- How to display the link (title) and thumbnail post?
- How to access $post from a callback function
- How to allow visitors to filter posts by multiple taxonomies
- Call Web Services on post first publish
- Override the WordPress core function wp_referer_field
- How to add_filter html template to middle of content
- disable Tab post on nav-menus page (Admin)
- What does WordPress do if I save a post without content/title? [duplicate]
- Every second post different class in blog view
- preg_replace not removed “class”
- Get post meta retrieving wrong value
- The_excerpt() doesn’t parse – how to change that?
- Divs appearing everywhere in post content
- Prevent posts with certain post_meta to be edited
- Add custom text automatically on each post
- How to have different site identity logos on each page on Astra Theme [closed]
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Same post appears in related Posts?
- Help on conditional statement to accompany wp_insert_post function please?
- user_has_cap filter allows “edit_others_posts” but not is not allowing updating/publishing
- get category in list of posts // shortcode for custom related posts
- Posting to WP via URL
- Randomize post (and page) IDs on generation
- Display/Filter post using if else statement
- How Do I Unhook This Parent Theme Function?
- Use action, filter, or hook to append HTML to WordPress plugin function
- Count singular post views automatically
- Replace Tag Keyword With Link Within Post Content
- Get post id outside loop : Notice: Trying to get property of non-object
- How do I change the post title’s link on the posts page?
- How to create frontend Post filter using meta query
- im trying make a function to auto correct posts when i open the posts in the backoffice
- How to test if user is filtering post list in dashboard
- How to change number of posts shown on homepage vs other pages?
- How to get posts from network blog
- Hook only specific post type
- Get post title by Alphabet
- Custom filter on all post page (admin backend)
- How can I create a menu items from meta box based on users input
- How to use wp_editor(); in functions.php then retrieve content in the template
- How *not* to show the last post on the latest posts list
- the_content() not displaying the full post
- wp trim function not working
- Insert Shortcode exactly at the end of the content
- display last post modified date in genesis child themes
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- How to Add Extra Text In WordPress Title Before Post Publish