Skip to content

Instantly share code, notes, and snippets.

@JulioPotier
Created December 8, 2015 22:48
Show Gist options
  • Save JulioPotier/bbc90dd08c29c50a20a8 to your computer and use it in GitHub Desktop.
Save JulioPotier/bbc90dd08c29c50a20a8 to your computer and use it in GitHub Desktop.
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