If the javascript code is actually embedded in the post content, you could use php filters such as the_content
to remove script tags. But that will strip it out at runtime, every time the page is loaded. If this is your situation, then you’d be better off stripping it out of the wp_posts.post_content
table/column from the database.
If you want to quickly strip out the content just for display, you can use the the_content
filter, like so (in your theme’s functions file)
add_filter('the_content', function($content){
return wp_kses_post( $content );
});
But again, this will run every time the page is loaded. It’s more of a short term fix.
Related Posts:
- Insert HTML just after tag
- the_content and is_main_query
- How to Pass External Variables to Filters/Actions
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Filter username field on registration for profanity and unwanted words
- At what priority does add_filter overwrite core functions?
- Add whitespace between Chinese and other letters
- How to add icons to post listing (edit.php) in admin
- Tiny MCE editor stripping xlink:href parameter from SVG USE tag
- Translating an error message
- Keep Users Logged In As Long As I Like
- Is it possible to remove the filter from 4.8 text widget?
- Overriding wp_get_archives() apply_filters()
- How to make post and comment count unclickable with dashboard_glance_items hook
- Call to undefined function error after adding add_filter to wp-config
- How to remove X-Frame-Options: SAMEORIGIN” from WordPress?
- Add Dropdown menu using “add_filter => wp_nav_menu_items”
- Filtering ‘the_title’ with option to return subhead?
- Setting title using wp_title filter
- What functions are included in apply_filter(‘the_content’)
- Filtering admin entries for custom post type
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- option_active_plugins filter not working
- How do we check if the user is logging in or registering?
- Anonymous function is executed twice in wp_head while added from the_posts filter?
- add_filter return value
- Why my admin doesn’t work after adding rest_prepare_post filter?
- How to make a button?
- How do I filter title and alt attributes in the gallery shortcode?
- remove_action in plugin file
- Filtering post-formats from the loop using new WP-Query();
- Filter Media by Featured on Admin
- How to add a filter to get_the_author_meta?
- page_attributes_dropdown_pages_args filter does not work
- What different ways can a plugin add a filter to a WordPress site?
- How to access plugin variables from theme templates without using globals?
- Make an array filterable per hook
- add img class to native wordpress galleries
- Get Posts updated or published within the last x hours
- preview_post_link for Custom Post Types
- Filter an array with a callback – for single & multidimensional arrays
- Detect when gutenberg editor title is available in Dom after editor load
- Why this filter hook is not working when passing parameters?
- Are href attributes of a elements filtered on output to add the current path?
- Add a filter to an action [closed]
- Regarding post text filtering
- Add Filter not working with get_posts
- How to Prevent WordPress to encode html in post?
- Why template_include filter does not work with WPML plugin?
- Why is overwriting $GLOBALS killing the_content()?
- Sorting products by price ( regular + sale price )
- WooCommerce coupon hook argument NULL when using filter woocommerce_get_shop_coupon_data
- Create new custom field that calculates age
- How can I edit comment meta value before it is saved?
- Why current_user_can(‘edit_comment’) always true?
- Remove comments validation (remove filter?)
- How to query if meta_key does exist or not?
- Redirect after post deleted
- Remove Site Name from wp_title WITHOUT removing from attribute
- Plugin default settings hook
- How to stop filter from running on the index.php page?
- Filter Shortcodes when using get_page
- Usage of filters
- add_filter to the_content after apply_filters
- Where exactly does the edit_{taxonomy} hook fire?
- How to filter with dropdown in backend for custom data
- Is there any reason for the nested filters to be applied on the first case and not in the second one?
- Best practice: Custom Post Type / Filter / Load more
- How to Edit Ecommerce filters URL, h1, h2 , Title
- Redirect an archive page to its relevant URL-friendly filtered page
- Run `wp_insert_post_data` on all posts
- Show uploaded pdf files dynamically and filter by month name
- How can I pass instance via apply_filters as a parameter?
- how to use substr with get_the_content()
- AJAX Post Filter
- Add filter return false not working
- How to add markup to the wp-custom-header div
- How to take shortcode and content separately from a page?
- Display post after choice two taxonomy terms
- How to stop echoing gallery inside content?
- how to filter datalist table of wordpress
- Ajax Filtering Pagination
- Apply a filter str_replace on specific caracters array in the_content()
- get_the_archive_title hook unwanted changes!
- Is there a function to edit Blogs contents in Blogs page?
- Can’t set properly WordPress add_filter function
- Hook inside a hook
- apply_filters to $GLOBALS
- How to filter content in Dashboard?
- The title of an attachment is not working
- Removing a line from a WP core function (comment_template.php) – filter or other technique?
- How to remove a filter that is an anonymous object?
- Hide H1 Title using the_title filter
- get_the_excerpt on mobile still displays continue reading
- Date filter for post query not filtering results when variable outside the function
- Filter image and text from post format
- Filter and Search
- Remove pipe in views admin page filter
- Hooking/Filtering theme name to add theme directory
- How to use filter in this situation, can not modify the structure using filter