relevanssi_the_tags( $before = null, $separator = ', ', $after = '', $echo = true, $post_id = null )

Replaces the_tags(), but applies Relevanssi highlighting to the list of tags it prints out.

Source: /lib/utils.php


(string) (optional) A string that is printed out before the list of tags.
Default: null

(string) (optional) The separator string between the tags.
Default: ‘, ‘

(string) (optional) A string that is printed out after the list of tags.
Default: an empty string

(boolean) (optional) If true, echo out the result. If false, returns the result.
Default: true

(int) (optional) The post ID to use.
Default: the current post (in Loop)


If $echo is false, returns the tag list as a string.


This function behaves like the_tags(), you can use the same parameters (except this function can be used outside the Loop by specifying the post ID, that’s not possible with the_tags()).

This function uses get_the_tag_list() to get the tag list, then applies Relevanssi highlighting with relevanssi_highlight_terms(), getting the search query from get_search_query(). Some extra adjustment is made to ensure highlighting is only applied to the names of the tags, and not inside hyperlinks, for example.

The original function only displays the tag list, this can be also used to just fetch the tag list. If you want to stick with the standard naming conventions, you can use relevanssi_get_the_tags(), which acts as a wrapper for this function:

relevanssi_get_the_tags( $before = null, $separator = ', ', $after = '', $post_id = null )