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)
- Modify upload directory to use post category slug in file path on multisite installation
- Add function to single blog post pages only
- Exclude category from
- Setting posts_per_page for taxonomy term template
- How to filter, restrict and return posts based on custom user meta information
- Adding buttons to Add New Post and Add New Page
- How to hide html tags on revision comparison pages?
- Add filter by custom field to block of posts
- How to display the link (title) and thumbnail post?
- Ajax post filters not working
- Default to ‘all’ view on the ‘edit-post’ screen for authors
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Hide a specific category in admin All Posts page (WordPress)
- Force the “Choose from the most used tags” meta box section to always be expanded
- Show the content that is after the excerpt using child theme
- Display Meta Values in Custom Filter – Admin Custom Posts
- How to allow users to post only in certain category and hide elements from edit page?
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- How to filter my search in post if contains a word in title, content or excerpt?
- More then one menu items are assigned with “current-menu-item” class
- Update post_content everytime a custom post is opened in backend
- How to access $post from a callback function
- How to do set post permalinks using 6 digit random unique function?
- Can’t get buddypress notifications in front-end; why do I get this error?
- Getting Custom Post Loop to display in Bootstrap 3 column grid
- Updating post data on save (save_post vs wp_insert_post_data)
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Replace a menu with widget or a custom template file programmatically
- Posts and Attachments with “Published” status in Search
- Send post id through ajax and get the post content back
- Display post x of y within category
- Force authors to Preview a post before publishing
- WordPress Automatic Filename Changer
- How to allow visitors to filter posts by multiple taxonomies
- Copy post to separate database with “add_action(….)”
- Hooking into the post editing screen for an existing page only
- Redirect to another page using contact form 7? [closed]
- Order posts alphabetically: how to set order=asc in mysql query?
- Call Web Services on post first publish
- Override the WordPress core function wp_referer_field
- add to end of post in the loop with plugin
- Make wp_link_pages() suitable for Twitter Bootstrap markup
- Add filter to the end of the post
- How to dynamically parse and transform post/page content before displaying it?
- How to edit the Tags within the image file URLs?
- Can’t properly set the_title add_filter to show short_URL
- Get post content with all filters applied, knowing post id
- Change all author links in Blog roll
- How to add_filter html template to middle of content
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- disable Tab post on nav-menus page (Admin)
- (Woocommerce) Order by price when entering specific category
- What does WordPress do if I save a post without content/title? [duplicate]
- Is it possible to filter the main loop to exclude posts from a specific category?
- add bootstrap post slider with tabs
- Every second post different class in blog view
- Format latest/newest post differently
- is_page Funtion for Posts ?
- query post limits
- Post type no single page
- preg_replace not removed “class”
- why the same code got different results when using query_posts in functions.php and index.php
- Get post meta retrieving wrong value
- Adding a user’s ID behind the tag ref link address
- The_excerpt() doesn’t parse – how to change that?
- Divs appearing everywhere in post content
- How to only publish posts with image in it
- Isn’t the way posts are displayed very unefficient?
- Filtering posts on Post Administration Page by Week Number instead of by Month
- Prevent posts with certain post_meta to be edited
- Add custom text automatically on each post
- Call to undefined function is_home() or any conditional tags
- Possible to hook into Media Library preview File column and use a custom image?
- How to check in functions.php if there is data in a WP_Query?
- Change the default blog post post attribute template name from “default template” to something else
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- restrict incrementation of post vies count when refreshing the page
- How to have different site identity logos on each page on Astra Theme [closed]