Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
add_filter( 'the_title', 'baw_add_color_to_title' );
function baw_add_color_to_title( $title ) {
global $post;
if ( is_single() ) {
$term = get_the_terms( 0, 'category' );
if ( $term ) {
$term = reset( $term );
$color = get_term_meta( $term->term_id, 'color', true );
$title = sprintf( '<span style="color:%s">%s</span>', esc_attr( $color ), $title );
}
}
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment