Try this code in your theme’s functions.php
file-
function filtered_content($content){
$content = preg_replace("/<img[^>]+\>/i", "", $content); // removes images
$content = preg_replace('/<iframe.*?>/', "", $content); // removes iframes
return $content;
}
add_filter('the_content', 'filtered_content');
This will remove img and iframe tag from your content. Then use the_content()
in your template.
Related Posts:
- WordPress Ajax filter: Create two loops for different output styles?
- For each loop will not append to the_content hook
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Show related products by attribute based and certain conditions
- How can I add diffrent editable text fields?
- How to Create custom block for displaying information in content section which act like shortcode
- How to Add a cutsom slug to my custom author role
- Filter wordpress posts without searching the keywords in the post content
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- Variation prices breakdown only for single product page
- Give ID to divs inside the loop
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Filter ‘comment_notification_text’ not working
- Remove Author Links
- Products listing check if meta checkbox is checked
- Pagination contents not changing in Front page WordPress
- Copying and pasting to WordPress “code editor” code via the front end and clipboard
- How to run php code only for a specific widget on a page and not all widgets on that page?
- Display articles with a different template in the home page | Solved |
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- in_array not working on dev server but works on localhost
- How to Create Carousel Indicators in PHP Loop using wp_get_attachment_url function?
- How to output the taxonomies that are assigned to each custom post?
- Apply function.php filter only if url not has /amp/
- Change the “Show All” button in a WordPress Portfolio Filter
- Get title of page containing post grid within the posts
- Check if current post in loop is last on current page
- Trim Titles Only On Some Pages
- update_user_meta as multiple value but with same meta key
- How to use apply_filters() inside a plugin class?
- Change lost password url to a mailto URL in WordPress
- Is there anyway I can call the year once?
- Shortcodes not processing inside post content
- Remove span tags from WooCommerce Downloads page
- Display all categories including sub categories under a list ul
- How to edit post meta data before publishing the post it self wordpress?
- Multiple Tag Filtering
- Responsive loop with 3 columns inside row then 2 columns
- Add a top bar to a wordpress theme without editing the header.php file?
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- Looping through dummy posts and showing them in the main index.php
- Where does php code to load data go?
- I want to hide “sold by” on certain pages with id page 43
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- Should I set a page as “No-index” if I include it’s content within the front-Page.php via this method?
- using filter and hook inside class
- Custom Loop.php having a loop inside a loop
- ACF – Get ID of relationship field in flexible content
- cURL needing to loop through all “next_page”
- Display page content in different sections – based on page break block?
- How to bind each “the_content” elements to a custom variables
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- How to change href of a Widget menu item link?
- Latest posts feed with a specific post always first
- Show the subcategory name based on current product
- Reload page with a different shortcode when a user selects from a dropdown
- Filter portforlio with librairie isotop
- How to output values from a loop into a javascript array
- How to display sticky post always at the top (before regular post) in wordpress?
- add_filter() inside another add_filter()
- How to filter specific element of an array in wordpress/php?
- How to disable sub menu items from being created?
- adding or removing endforeach; throws error!
- Return to the beginning of the results of a for loop
- How to count posts posts if they are in a separate content page?
- Redirecting the lost password page request when using a custon login page
- Adding PHP to an if else loop
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- WordPress Recent Posts – Loop
- Exclude category and post from loop in custom category.php
- How to display custom seo title before the loop?
- ACF background-color per post in a WordPress loop
- How can i style “echo apply_filters”
- Adding body class to html tag that already has language attrubutes?
- How can I get my pagination loop to display the correct number of total pages?
- Custom Bulk Actions handler not firing
- Advertisement in Loop Posts wordpress
- How do if all posts has this category ID then do this
- Thumbnail wouldn’t scale to size properly
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- How to generate customized filtered output for the gallery
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- dynamically change content of div with php
- Date of last blog update for specific authors only?
- Add class to all meta boxes for a custom post type
- View tag description on page
- Making list of posts with chosen description
- Add a leading zero to pagination
- Filter loop by ‘price’ with meta_query
- Get current_post in reverse order with pagination
- How to remove title tag with this filter
- PHP for loop not working as intended
- How fix error in the WordPress loop?
- How to add text before posts
- what’s the syntax for if the image exists get the image?
- Adding custom PHP to existing loop in Genesis
- How to Pass Current Taxonomy Terms into new WP_Query?
- Problems with the WordPress loop [closed]
- str_replace not preserving whitespace