function abc_the_content($num_words) {
global $post;
$content = $post->post_content;
$content = strip_tags($content);
$content = wp_trim_words($content, $num_words, $more = null);
echo apply_filters('the_content', $content);
}
change the strip tags line to this one if you want to strip out only the img tag
$content = preg_replace("/<\/?img(.|\s)*?>/i", '', $content);
Related Posts:
- Difference between the_content() and get_post()?
- Insert Ad Code in the Middle of a Post
- get_the_excerpt() not returning anything when post has no excerpt
- Function to wrap the_content in a div
- Function to show only first instance of shortcode
- Automatically insert php function into post $the_content
- Searching for content post
- str_replace function in theme
- Adding HTML to the end of every post with the Block Editor
- Inserting a functions output after the content
- Add caption functionality to custom WordPress theme
- Removing permalink from post thumb in twentyeleven
- Add Element as a Filter to the_content
- Insert template-part inside the content
- Remove links from the_content when using filters wp_trim_excerpt
- How do I pull excerpts from pages?
- does wp function the_content(); accept another tag inside
- Undefined variable error in new function
- How to remove a specific word at the beginning of the content and add it to the end of the content
- The_content and Preg_replace in loaded Iframe [closed]
- first paragraph of the_content as meta description
- Changing where my author box is printed
- Insert Content Before div#main from the functions.php File
- If is_single in functions.php
- Conditional function for excluding first image from content, not working
- Strip all HTML tags from product content and resave
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- $content is empty while using DOMDocument
- Shortcode to eliminate and replace with
- Function the_content
- How accomplish modification the_content if home/start page?
- Creating mixture of shortcodes to use in the visual/text editor
- Solution to render Shortcodes in Admin Editor
- How to run a function every 5 minutes?
- Define page template in wp_insert_post
- Child theme functions.php do I use php open and close tags?
- Modify Admin Bar Link
- How to override admin-bar style
- WP 4.4. responsive loads normal image after loading the responsive image
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- How can I tell if I’m on a login page? [duplicate]
- Get Category and Excerpt From wp_get_recent_posts
- Two different menus for two different locations?
- Error after editing functions.php
- Most efficient way to get custom database records from 20 buttons and 20 tables?
- Manipulate Output of wp_list_something: select menu instead of li’s
- Empty Date Returned on my function
- Woocommerce Attributes pulling in wrong data
- How to get the post_name when in preview?
- “is_new_day()” alternative for years?
- How to hide a plugin metabox for non admins when a user adds a new post
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Echo tags used to describe the theme
- How can I change a function in a parent theme via a child themes functions.php
- How can I make a widget shortcode to control all the widgets?
- admin-ajax.php + load-scripts.php hanging for minutes
- Unique sequential reservation code
- Show image exactly defined to a width
- Override the WordPress core function wp_referer_field
- Is `is_sidebar_active()` deprecated, and showing error?
- How to return hook data when multiple parameters are present?
- How to add_filter html template to middle of content
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Where to call my pagination function?
- Can’t locate custom image sizes defined by child theme
- How to map numbers utilizing array function
- Add attribute only to first image of every post via functions.php
- 400 Bad Request – JavaScript App calling Custom wp-json endpoint
- Check if a value exists in database table
- Are innerHTML elements visible to jQuery functions?
- Help with IF has focus then… statment
- How d0 i get the number of attachments in the post
- How to use wp_enqueue_script properly?
- This code is supposed to only allow user to be authenticated if accountVerified is equal to 1, but it still allows user to be authenticated otherwise
- Get webpack to work on child theme
- Hide ‘add to cart’ when certain value in dropdown is selected
- Enqueue script if not page template
- How do you insert code into the sidebar?
- Test CDN link from function.php or wp_enqueue_script/style?
- How to bind each “the_content” elements to a custom variables
- Auto Resize embedded videos player
- Can site visitors view functions.php file?
- Images with overlay
- Combine multiple menus using the filter wp_nav_menu_items
- Changing author links on homepage to buddypress profiles – without affecting ability to link to author archive throughout the site
- WordPress function with attribute pass to template
- Taxonomy On Index Page
- I see edit instead of read more
- Zip all (original) images from media gallery
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- How to replace words in my posts and saved new words
- Why might wptexturize have become re-enabled?
- Problem in shortcode outputting content
- How to use different jquery function of idangero swiper dependant on page template?
- Why does modifying my functions.php file always result in a server error
- wp_get_current_user->user login returns %20 for spaces
- Disable every rss feed except home feed
- If two tags in the middle i need comma
- sort by date in users