Last active
October 4, 2016 08:04
-
-
Save kurudrive/22d2a04452596ab423ad77dc47cf7c6a to your computer and use it in GitHub Desktop.
Lightning のカテゴリーの色を設定する
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
<?php | |
add_filter('vk_post_list_widget_li_items', 'veu_new_post_widget_term_color'); | |
function veu_new_post_widget_term_color($li_items_output){ | |
$taxonomies = get_the_taxonomies(); | |
if ($taxonomies): | |
// get $taxonomy name | |
$taxonomy = key( $taxonomies ); | |
$terms = get_the_terms( get_the_ID(),$taxonomy ); | |
$term_html = ''; | |
foreach ($terms as $key => $term) { | |
$term_name = esc_html($term->name); | |
$term_color = Vk_term_color::get_term_color( $term->term_id ); | |
$term_color = ( $term_color ) ? ' style="color:#fff;background-color:'.$term_color.'"': ''; | |
$term_link = esc_url( get_term_link( $term->term_id, $taxonomy ) ); | |
$term_html .= '<a class="padCate"'.$term_color.' href="'.$term_link.'">'.$term_name.'</a>'; | |
} | |
endif; | |
$li_items_output = '<span class="published entry-meta_items">'.esc_html( get_the_date() ).'</span>'; | |
$li_items_output .= '<span class="taxonomies">'.$term_html.'</span>'; | |
$li_items_output .= '<span class="entry-title"><a href="'.esc_url( get_the_permalink() ).'">'.esc_html( get_the_title() ).'</a></span>'; | |
return $li_items_output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment