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