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