How to use the ‘comments_number’ filter?

Question

I’m not sure how to use this filter. Could someone show me an example? I’m trying to change ('0', '1', '%') to ('0 Comments', '1 Comment', '% Comments').

I’m using this function to get the comments number.

    function lpe_get_comments_number( $anchor='#comments' ) {
        $return = '<a class="comments-number-link" href="' . get_permalink() . $anchor . '">';
        $return .= get_comments_number(); // '0', '1', '%'
        $return .= '</a>';
        return $return;
    }

I know I could just set the arguments here and call it a day, but I was hoping to store my custom functions away in a different file and handle their settings from the themes functions.php.

0
, , Marc Wiest 2 years 2020-09-02T21:10:59-05:00 0 Answers 50 views 0

Leave an answer

Browse
Browse