Filters and Actions (Hooks)

Hook into an action with add_action(). Example:

function group_is_gone_message( $group_id ) {
 echo "Group {$group_id} is gone!";
}
add_action( 'term_group_deleted', 'group_is_gone_message' );
Action nameArgumentsWhen triggered
term_group_savedvoidafter information about (one or more) term groups was saved
term_group_deletedinteger: group IDafter a group has been deleted
groups_of_term_savedinteger: term ID
integer or array of integers: tag group IDs
after a term’s assignment to groups was saved

Hook into a filter with add_filter(). The function should return the modified first argument. Example:

function wrap_as_gift( $html ) {
 return "<div class='wrapping_paper'>" . $html . "</div>";
}
add_filter( 'tag_groups_post_terms', 'wrap_as_gift' );
Filter nameArgumentsFilters what
tag_groups_view_{$view_slug}string: content (HTML)filters a string that contains the HTML of a view before output. Find possible view_slugs in the code (in the “view” folders, the part before “.view.php”)
tag_groups_post_terms
(premium only)
string: content (HTML)filters a string containing the table of post tags, in TagGroups_Premium_API::post_terms
tag_groups_cloud_tag_innerstring: content
integer: term ID
string: shortcode identifier
filters all tag names in tag clouds
tag_groups_cloud_tag_outerstring: content (HTML)
integer: term ID
string: shortcode identifier
filters all tag names in tag clouds, including the wrapping <span> element
tag_groups_cloud_htmlstring: content (HTML)
string: shortcode identifier
array: shortcode parameters
filters the complete HTML output of all tag clouds
tag_groups_template_custom_field (since version 1.33.0)mixed: value returned by get_post_meta()
string: custom field name
integer: post ID
filters the value of a custom field for output in a post template in the Toggle Post Filter, Dynamic Post Filter or Post List; must return a string
tag_groups_tag_title (since version 1.33.0)string: title
string: shortcode name
string: tag description
integer: tag count
filters the HTML title attribute of each tag that appears as tooltip on mouseover

How do you rate this article?