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
- Use AJAX in shortcode
- 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?
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Creating a table from shortcode avoiding wpautop for each row
- 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
- Shortcode to insert menu in page body?
- get_the_excerpt() not returning anything when post has no excerpt
- Passing HTML in WordPress Shortcode arguments
- Allow latex in wordpress excerpt
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- creating shortcode to pull json array
- Custom Shortcode, functions PHP WP_Query loop
- Pass Shortcode Attribute to footer Script
- Super simple shortcode not working
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Display gallery on top before content
- Using “Read More” link with custom excerpt
- How to extract the variables out from “add_shortcode” function?
- 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?
- Shortcode pagination not advancing
- 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
- Limit length of first excerpt in the loop
- How to filter $content in shortcode function
- Setting youtube size in functions.php
- Display gallery on bottom after content
- WordPress Shortcode function display outside of widget
- check if the user is owner of current page
- shortcode help require
- Optimizing a WordPress site
- Use html inside shortcode function
- Shotcode argument issues
- Exclude category from shortcode
- 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?
- Use a shortcode to display custom meta box contents
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- WordPress Excerpt – How to remove the first link using functions.php
- How to include any template using Shortcode fuction?
- How to create shortcode with html and php content?
- Tracking the number of shortcodes for a list?
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- Shortcode to get featured image of specific id post
- Limit number of characters in different excerpts
- show all the posts thumbnails
- the_excerpt function not showing image
- Problem with shortcode inside a shortcode
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Display a list of random terms from custom taxonomy with shortcode
- page shows short code not output
- Last updated posts shortcode in functions.php
- Appending „read more” to the excerpt conditionally
- How to retrieve image IDs from shortcode content?
- Display list of pages that contain a certain string within the slug
- HowTo: Add wrapper to columns shortcode?
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- How to make an If Else on Excerpt Filter
- Custom shortcode with do_shortcode and substr
- Can I use a function to return HTML and the result of another function?
- getExcerpt: Make ellipsis appear only if character limit is reached
- need help with ‘… read more’ excerpt in functions.php
- Expanding a function to call a plugin or show a link
- Excerpt length: get 2 paragraphs
- Trying to the deduce shortcode from a function
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- restrict access to specific urls on a specific period of time
- Run function from parent on child site
- Add title & subtitle to shortcodes
- Shortcode Variations?
- shortcode inside post called by ID does not render as expected
- Excerpt – First Sentence & Read More
- Custom shortcode not being included in content paragraph [duplicate]
- Display function from functions.php in tag.php
- Creating mixture of shortcodes to use in the visual/text editor
- multible shortcodes (for differnt values) with one function