Skip to content

Commit

Permalink
fix #76
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed Nov 15, 2019
1 parent fbcb523 commit 679afaf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sempress/inc/semantics.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,38 @@ function sempress_semantics( $id ) {
echo ' ' . esc_attr( $key ) . '="' . esc_attr( join( ' ', $value ) ) . '"';
}
}

/**
* Add `p-category` to tags links
*
* @link https://www.webrocker.de/2016/05/13/add-class-attribute-to-wordpress-the_tags-markup/
*
* @param array $links
* @return array
*/
function sempress_term_links_tag( $links ) {
$post = get_post();
$terms = get_the_terms( $post->ID, 'post_tag' );

if ( is_wp_error( $terms ) ) {
return $terms;
}

if ( empty( $terms ) ) {
return false;
}

$links = array();
foreach ( $terms as $term ) {
$link = get_term_link( $term );

if ( is_wp_error( $link ) ) {
return $link;
}

$links[] = '<a class="p-category" href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
}

return $links;
}
add_filter( 'term_links-post_tag', 'sempress_term_links_tag' );

0 comments on commit 679afaf

Please sign in to comment.