Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: post_class_taxonomies

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
563       * Default is all public taxonomies registered to the post type.
564       *
565       * @since 6.1.0
566       *
567       * @param string[] $taxonomies List of all taxonomy names to generate classes for.
568       * @param int      $post_id    The post ID.
569       * @param string[] $classes    An array of post class names.
570       * @param string[] $css_class  An array of additional class names added to the post.
571      */
572      $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $css_class );
573
574      foreach ( (array) $taxonomies as $taxonomy ) {
575           if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
576                foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
577                     if ( empty( $term->slug ) ) {
578                          continue;
579                     }
580
581                     $term_class = sanitize_html_class( $term->slug, $term->term_id );