After some Googling, I found a solution that was originally done for a Twitter embed, but I modified it to work with all oEmbed contents. Keep in mind that for this to work on existing posts, you’ll need to do an “update” for the oEmbed content to refresh from the cache.
add_filter('oembed_result','center_oembed',10,3);
function center_oembed($html, $url, $args) {
$html="<p style="text-align: center;">" . $html . '</p>';
return $html;
}
Related Posts:
- How can I replace an oEmbed URL in post with actual embed HTML
- Add an attribute to the root from functions.php with add_filter
- How to pass/get data to/from the WooCommerce data-product_variations object?
- What does (10, 2) mean when used with add_filter
- Clarification on filters and hooks
- Passing Additional Parameters to add_filter Callable
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Custom theme hooks / filters – passing arguments
- Adding a class to the body_class function
- How to hook wp_list_pages?
- How to make post and comment count unclickable with dashboard_glance_items hook
- How to use the_excerpt in a filter hook?
- Add wrapper to only youtube videos via embed_oembed_html filter function
- Hook into admin post list page
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- How can I hide all posts that don’t have a thumbnail?
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- How can I reliably and globally disable wptexturize?
- Customise Jetpack Publicize text
- WordPress RSS feed – filter RSS content by custom field value
- filter the_title problem in nav
- Add classname to the_category() function?
- Filter the URL of next_posts_link & previous_posts_link
- How to get list of all hooks of current theme / plugin?
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- How to replace any occurence of Gravatars with a local placeholder image?
- Sensei LMS Hooks to Remove Content
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- Change WordPress RSS link with filter?
- Add a header before fields added with the attachment_fields_to_edit() filter
- Hide content editor for posts after approriate date
- Gutenberg disable the “block” tab in right sidebar
- Why my admin doesn’t work after adding rest_prepare_post filter?
- add_filter() function misunderstanding
- Where is this inline CSS code [closed]
- When to use actions and when to use filters
- add_filter to ‘woocommerce_before_main_content’ [closed]
- Editing
- Same Conditionals Not Working on Two Different Hooks
- Filter or Hook to catch pre-rendering of post content
- Can the wp_filter object hold multiple values with the same key
- check to see if hook is available
- apply_filters/do_action tag characters limit
- Insert term when page is published – avoid duplicates after edits
- How to modify core when there is no hook?
- When does a function assigned to the content_filtered_edit_pre filter hook fire?
- Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?
- Post Content, Special Characters and Filters
- Capture post content before page renders
- Remove_action does not work
- How to remove action with slashes and arrows?
- Header image automatically changes depending on season
- Better extend a class or use add filter/action hooks?
- Add content as soon starts
- Make an array filterable per hook
- Changing WordPress core without hacking core
- Comment search plugin
- Plugin options, presets and filters : can you help me improve my workflow?
- how to customize rss feed tags using hooks?
- Woocommerce “added to cart” message on main(home) page
- Wrapping my head around add_filter
- Detect when gutenberg editor title is available in Dom after editor load
- Gutenberg Block – Post Featured Image Filter Hook
- Is it possible to bind a function to a filter hook via Ajax?
- Change custom post type GUID in RSS
- filter hook to load a different post/page on current post/page
- Remove tags without a specific meta key from “choose from the most used tags”
- Redirect to woocommerce checkout after adding to cart – item already in cart
- How can I edit comment meta value before it is saved?
- Action hook to control access to certain parts of my site
- Where exactly does the edit_{taxonomy} hook fire?
- Is there any reason for the nested filters to be applied on the first case and not in the second one?
- Same URL for portfolio and for a page creates 404 error. Is there any filter that i can use for a child page?
- Filter Media by attached page or blog post in Library
- How do I add a line break to a string that is output by PHP?
- Filter widget_posts_args not working
- style_loader_tag not changing stylesheet to preload
- Mystery line break
- Right filter for rewriting page statuscode
- Add filter return false not working
- oembed_dataparse filter not running at all for standard YouTube embed
- Security question – Display a General Custom Login Error Message
- Filter wp_mail based on content type
- get_the_archive_title hook unwanted changes!
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Hook inside a hook
- Adding user filter – Not updating data in URL
- How to check which submission button was clicked?
- WP Dashboard -> Posts-> Filter by Category -> Form Method Change : Which Hook
- Hide H1 Title using the_title filter
- Add class to all parent elements inside the_content
- Add Default WordPress Formatting To Data From External SQL Tables?
- Which hook should be used in this case?
- Getting entry ID from frm_email_message filter in formidable
- Auto append text after the title?
- How to use apply_filters(‘get_calendar’) to change get_calendar() output?
- Can you call a filter hook by “add_action”?
- How to elect position of new item output in a dropdown when using add_filter
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?