Don’t use a custom function. You should use the hooks. You don’t have to strip shortcodes, wordpress does that for you automatically, just use something like this
// setting higher priority so that wordpress default filter have already applied
add_filter('the_excerpt', 'custom_excerpt_filter', 11);
function custom_excerpt_filter($excerpt) {
// apply your logic of read more link here
return $excerpt . 'Custom Read More Text';
}
add_filter('excerpt_length', 'custom_excerpt_length');
function custom_excerpt_length($length) {
return 30; // replace this with the character count you want
}
RULE OF THUMB
Never Ever create a custom function for something there is a hook or core function available
Related Posts:
- Remove images from get_the_excerpt
- Excerpts are not displayed by a shortcode on category pages
- Hide disclaimer from summary excerpts
- Solution to render Shortcodes in Admin Editor
- Use AJAX in shortcode
- Include PHP file in Content using [shortcode]
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- Check if the user has explicitly set an excerpt
- How to display random users with avatars
- How to override function in functions.php of parent theme?
- Enabling shortcodes for custom fields
- Show Video in Excerpt
- How to use get_media_embedded_in_content function
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Shortcode with parameters inside parameters
- When is wp_trim_excerpt() called?
- Creating a table from shortcode avoiding wpautop for each row
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Display random text from a file with the WP built-in AJAX API
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Shortcode with custom content attribute?
- Custom page template how to check is_page from functions.php?
- display public excerpt for private post
- Problem with extract() with custom shortcode
- Shortcode to insert menu in page body?
- get_the_excerpt() not returning anything when post has no excerpt
- get excerpt without images
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Passing HTML in WordPress Shortcode arguments
- Adding body class when post contains a specific shortcode
- Allow latex in wordpress excerpt
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- Custom excerpt legnths for specific pages
- creating shortcode to pull json array
- Custom Shortcode, functions PHP WP_Query loop
- Pass Shortcode Attribute to footer Script
- Super simple shortcode not working
- Detect Safari desktop browser and include the detection in a shortcode
- How to filter out shortcode when displaying the_excerpt() in the loop?
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- Display gallery on top before content
- Using “Read More” link with custom excerpt
- List child pages of specific page using shortcode
- How to extract the variables out from “add_shortcode” function?
- Display first name of logged in user?
- How to get specified parent page title in my function
- How to display post content instead of excerpt
- Possible to display shortcode based on the category?
- WordPress shortcode attributes for database SELECT?
- Shortcode pagination not advancing
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Having issues with a foreach inside of a shortcode with ACF gallery
- Shortcode inserts paragraphs before and after executing shortcode
- Using Schema with `the_excerpt`
- Display post shortcode content in the sidebar?
- How to get the index number of the posts?
- Using shortcode content with nested shortcode
- Custom Post excerpt not working correctly
- How can I make a widget shortcode to control all the widgets?
- Limit length of first excerpt in the loop
- Custom shortcodes not inserting into visual composer columns
- How to filter $content in shortcode function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Setting youtube size in functions.php
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- new_excerpt_more link not working properly
- Display gallery on bottom after content
- Add button to kitchen sink toggle
- WordPress Shortcode function display outside of widget
- check if the user is owner of current page
- shortcode help require
- Optimizing a WordPress site
- Help With Creating Shortcode
- How to display retweet count and likes in the meta above the excerpt
- Use html inside shortcode function
- Setting a default text for excerpts of a particular category
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- Exclude category from shortcode
- wp_nonce_field is breaking form for reasons unknown
- Remove links from the_content when using filters wp_trim_excerpt
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Excerpt for pages not showing
- get_pages() Returns Only One Item
- Function shortcode – Set Parameter
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Use a shortcode to display custom meta box contents
- Echoing function into WordPress NextGen gallery
- How do I pull excerpts from pages?