The way you are using the filter is wrong. Your function should accept the excerpt as an argument:
function custom_excerpt( $excerpt ) {
Then you don’t need to do the get_the_excerpt()
call, as you already have the value you want to edit. Furthermore, if you are replacing each word, one by one, you could hurt other parts of the excerpt, so I’d advise you to remove the whole sentence in a single call of str_replace()
.
Related Posts:
- Check if the user has explicitly set an excerpt
- How to override function in functions.php of parent theme?
- Show Video in Excerpt
- When is wp_trim_excerpt() called?
- Stripping shortcode from custom excerpt function
- Remove images from get_the_excerpt
- Custom page template how to check is_page from functions.php?
- display public excerpt for private post
- get_the_excerpt() not returning anything when post has no excerpt
- get excerpt without images
- Allow latex in wordpress excerpt
- Custom excerpt legnths for specific pages
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Using “Read More” link with custom excerpt
- How to display post content instead of excerpt
- Using Schema with `the_excerpt`
- Custom Post excerpt not working correctly
- Limit length of first excerpt in the loop
- new_excerpt_more link not working properly
- Excerpts are not displayed by a shortcode on category pages
- How to display retweet count and likes in the meta above the excerpt
- Setting a default text for excerpts of a particular category
- Remove links from the_content when using filters wp_trim_excerpt
- Excerpt for pages not showing
- How do I pull excerpts from pages?
- Strip div From Excerpt
- How to change value of variable in theme file with functions.php WordPress?
- first paragraph of the_content as meta description
- Adding Read More to Custom excerpts
- Limit number of characters in different excerpts
- wp_get_archives() output
- the_excerpt function not showing image
- Appending „read more” to the excerpt conditionally
- Hide disclaimer from summary excerpts
- How to make an If Else on Excerpt Filter
- getExcerpt: Make ellipsis appear only if character limit is reached
- need help with ‘… read more’ excerpt in functions.php
- Excerpt length: get 2 paragraphs
- Check if excerpt is empty at loop-portfolio
- Can’t change excerpt length and more tag
- More link – not text
- How to add an excerpt and read more link to a page?
- Adding a filter to my posts
- Excerpt – First Sentence & Read More
- function to show youtube videos within excerpt – if condition and apply_filters
- get php variable from functions php and echo it in theme template files [closed]
- Remove Container Element From wp_nav_menu() Markup
- WordPress function like is_category for subcategory? is_subcategory?
- Using a private method as an action callback from within a class
- Auto close (hide) custom metabox / set default state
- Does WordPress Development Mode Exist (with not minified JS)?
- WP_Query in functions.php
- wp_delete_user with username
- what is the meaning of settings_fields()
- Organize functions.php
- How to activate “Description” metabox for menu item programmatically?
- Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
- How to set child post categories to parent post categories when updating parent post?
- WooCommerce add_action hook results in 500 error
- Advice: Template structure – php blocks in sidebar or someting else?
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- Removing the first image in content
- Make menu structure match page heirarchy on page parent change
- Global functions on WPMU
- is_account_page() change to page slug
- Help with WP gallery function, wrap gallery in div
- set_post_thumbnail when user is not logged in
- Can you put a condition on add_image_size() depending on the width of the uploaded image?
- Force to use STRONG users password and implement rule to prevent REUSE [closed]
- Adding an external HTML link to a post thumbnail
- Overwriting the menu break points of twentysixteen in child theme
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- Passing User_Fields to Contact form 7 [duplicate]
- How can this crude function be improved?
- Help With Creating Shortcode
- How to hide image-url if no attachment?
- Solved: redirect to another page using functions.php
- Getting the teaser text without overriding global variables
- Function to pull data from user meta not working
- referencing the current user in a page i created in wordpress
- Counting posts and trigger it [closed]
- Is it possible to use ‘wp_insert_post’ function within a for loop?
- save_post function keeps triggering: Warning: array_map(): Argument #2 should be an array… when restoring from trash
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Trim excerpt to first paragraph
- Best way to add image to recent posts widget?
- Issues with add_query_arg() not passing a variable
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- Undefined offset: 2
- Sorting date results from a query
- Using is_plugin_active within functions.php
- Button generate a random URL [closed]
- How do I add functionality to images?
- How do i set global variable in a function in wordpress functions.php
- Working function() doesn’t execute when triggered by WP CRON