Skip to content

Instantly share code, notes, and snippets.

@kurudrive
Last active October 4, 2016 08:04
Show Gist options
  • Save kurudrive/22d2a04452596ab423ad77dc47cf7c6a to your computer and use it in GitHub Desktop.
Save kurudrive/22d2a04452596ab423ad77dc47cf7c6a to your computer and use it in GitHub Desktop.
Lightning のカテゴリーの色を設定する
<?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