Allow filters on custom excerpt
-
I needed a way to modify the custom excerpts in order to execute shortcodes as well as add “read more” link using advanced excerpts option values.
1) Modify advanced-excerpt.php under the class folder as follows:
Change line 232
Before
return $content;
After
return apply_filters( ‘advanced_excerpt_custom_excerpt’, $this, $content );
2) Add the following to your functions.php file:
add_filter(‘advanced_excerpt_custom_excerpt’, ‘my_advanced_excerpt_custom_excerpt’, 10, 2);
function my_advanced_excerpt_custom_excerpt($obj, $content) {
return $obj->text_add_more(
do_shortcode($content), $obj->options[‘ellipsis’], ( $obj->options[‘add_link’] ) ? $obj->options[‘read_more’] : false
);
}
- The topic ‘Allow filters on custom excerpt’ is closed to new replies.