Created
December 8, 2015 22:48
-
-
Save JulioPotier/bbc90dd08c29c50a20a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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