-
-
Save chocotaro/ccd18ed9599eb3f18e36f49bc527d1c7 to your computer and use it in GitHub Desktop.
新着情報などでAll-in-One Event Calendarのカテゴリ名を表示
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
<dl> | |
<?php //カレンダーのポストタイプはai1ec_event | |
query_posts( Array( 'post_type' => array( 'post', 'ai1ec_event' ), | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'paged' => get_query_var('paged') | |
) | |
); | |
if (have_posts()) : while (have_posts()) : the_post(); | |
?> | |
<?php //カテゴリスラッグ取得 | |
$cat = get_the_category(); $cat = $cat[0]; ?> | |
<dt><span class="<?php echo $cat->category_nicename; ?>"><?php the_category(', '); ?></span> | |
<span class="<?php //spanのclassに入れるためのリンク無しターム名(カレンダーのカテゴリ名) | |
$terms = get_the_terms( get_the_ID(), 'events_categories' ); if ( !empty($terms) ) : if ( !is_wp_error($terms) ) : ?> | |
<?php foreach( $terms as $term ) : ?> | |
<?php echo $term->name; ?> | |
<?php endforeach; ?> | |
<?php endif; endif; ?>"> | |
<?php //リンク付きでターム名(カレンダーのカテゴリ名)を取得 | |
echo get_the_term_list( $post->ID, 'events_categories' ); | |
?></span></dt> | |
<dd><?php the_time('Y年n月j日'); ?>|<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dd> | |
<?php endwhile; endif; wp_reset_query(); ?> | |
</dl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment