Send argumrnt to `excerpt_more` filter

Would one of your bad-asses like to recommend a way to send an argument to excerpt-more so that I could display the more link differently depending on where it was called from?

         * Clean up the_excerpt()
        function excerpt_more($source="general") {
            if ($source == "general")
                    return ' &hellip; <a class="continued" href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
                    return ' &hellip; ';
        add_filter('excerpt_more', __NAMESPACE__ . '\\excerpt_more');

You can’t pass arguments with the add_filter function. It’s reliant on the do_filter function. Generally it’s dependent on a page or type of post, so you can use those to check.

If it’s something specific and not applicable with a WP function, you may have to resort to a global or something, I dunno ¯_(ツ)_/¯

1 Like