Skip to content

Instantly share code, notes, and snippets.

@matadorjobs
Last active August 11, 2023 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matadorjobs/f42d64f940becb6b21eef376de6ac3a6 to your computer and use it in GitHub Desktop.
Save matadorjobs/f42d64f940becb6b21eef376de6ac3a6 to your computer and use it in GitHub Desktop.
Display count of jobs per term in a Matador taxonomy term list
<?php //omit opening tag
add_filter( 'matador_taxonomy_terms_term_label', 'matador_docs_matador_taxonomy_terms_term_label', 10, 2 );
/**
* Matador Docs Example: Add Term Count to Taxonomy Term Label
*
* In this example, display count of jobs per term in a Matador taxonomy term list.
*
* @since 2023-05-01
*
* @author Matador US, LP
*
* @param string $label
* @param \WP_Term $term
*
* @return string
**/
function matador_docs_matador_taxonomy_terms_term_label( $label, $term ) {
return '(' . $term->count . ') ' . $label;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment