In functions.php:
function myExcerpt($text) {
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 50; // max number of words
$words = explode(' ', $text, $excerpt_length + 1);
array_pop($words);
array_push($words, '-N');
$text = implode(' ', $words);
return $text;
}
In your loops:
echo myExcerpt ( get_the_content() );
Related Posts:
- How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
- add_action(), add_filter() before or after function
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- Trouble understanding apply_filters()
- What is the very earliest action hook you can call?
- the_content and is_main_query
- wp_headers vs send_headers. When to use each?
- How to appending to the_content using add_filter with custom post type?
- How many filter/action hooks are healthy?
- How to wrap an element around an iframe or embed in content automatically?
- WordPress Internal @ Mentions
- Earliest hook to reliably get $post/$posts
- Remove Editor From Homepage
- Where to hook into post content?
- What does (10, 2) mean when used with add_filter
- Valid characters for actions, hooks and filters
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- Insert Custom HTML After Shortcode
- How to check if a hook is hooked or not?
- Is it possible to use object in add_action?
- Add whitespace between Chinese and other letters
- Hook added to the_content seems to be called multiple times
- Get excerpt from $post->post_content
- Add Class to Specific Paragraph of the_content()
- add_filter for specific pages
- Store source permalink on XMLRPC calls
- What params are available with the_content filter?
- Using variable from one filter in another filter
- apply_filters(‘the_content’, $content) alternative
- What effect does the_content filter have on performance?
- How to make post and comment count unclickable with dashboard_glance_items hook
- Hook into admin post list page
- Anyway to edit the titlebar of WordPress Widgets in the Admin area?
- How do I know if author field was changed on post save?
- How can I display image metadata?
- Add post/page ID to inserted links within the_content
- Using hooks to place content in theme dynamically
- How to apply content filter permanently?
- How to prepend text to the_content, but after img/shortcode
- About Hooks and Filters
- PHP5, Inheritance, Singleton – action & filter hook limitations
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- Please explain me what the do_action does
- Format content value from DB outside of WordPress filters
- Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu
- add_action uses ‘echo’ add_filter uses ‘return’, why?
- What is the filter hook for custom fields content?
- changing variable through filters or action hooks
- Too many actions/filters!
- Apply a filter only once
- How to get list of all hooks of current theme / plugin?
- Making a class available via actions filters
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- What functions are included in apply_filter(‘the_content’)
- How to get current action?
- Filter Gutenberg Blocks Content
- Conditionally call add_action depending on post_type?
- Return array of images after content
- how to change appearence of the content of default post list columns?
- Nested calls the the_content filter
- Anonymous function is executed twice in wp_head while added from the_posts filter?
- Explanation for remove_filter used in the below code [closed]
- How to change the blog title with add_filter? details below
- How To Get User Data in Callback Function for pre_user_nicename?
- What’s the best way to split admin-only functionality in the theme’s functions.php file?
- Filter list by a unique meta value dilemma
- return values from hooks do_action and apply_filters, which is better
- How to get all the predefined do_action() calls from an active theme
- Is it possible to track down Actions and Filters?
- When to use actions and when to use filters
- Return a custom value in a function added to an action hook
- Editing
- the_content filter – checking the post
- Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
- Apply the_content filter, but prevent other hooked actions
- Same Conditionals Not Working on Two Different Hooks
- Wrap h1-h6 in a div
- How to call a function or method that is Namespaced using another plugin
- How to change currency programmatically on creating order action?
- add filter login_redirect does not contain original requested redirect
- get_header and hook avoid normal call
- Removing an action, or dequeueing style – Both not working
- Can the wp_filter object hold multiple values with the same key
- Function the_content not working
- apply_filters/do_action tag characters limit
- Replace a word with a word in the URL string
- Is there a filter called ‘network_admin_init’?
- How to add ‘total’ value to custom column title on the posts list page
- Filter taxonomy admin pagination
- When to use add_action when registering/enqueuing scripts
- Insert term when page is published – avoid duplicates after edits
- ‘the_content’ filter removing html tags from post content
- Are there actions or filters I can use for Ajax calls?
- add_filter(‘the_content’, ‘…’) stops pagination from working
- Post Content, Special Characters and Filters
- Capture post content before page renders
- Correct method of redirecting user login
- Shortcodes — Using add_action, add_filter in the shortcode
- How to remove action with slashes and arrows?
- Can the wordpress color palettes by changed through Javascript?