<?php
// 現在のロケールを取得
$locale = get_locale();
?>
<div class="entry_content">
<h1>tag list</h1>
<?php
$original_query = $wp_query;
// slug順にタグを取得
$tag_all = get_terms( 'post_tag', array(
'fields' => 'all',
'orderby' => 'slug'
)
);
foreach( $tag_all as $value ):
?>
<h2>tag-name: <?php echo $value->name; ?> <small>tag-slug: <?php echo $value->slug; ?></small></h2>
<?php
$arg_tag = array(
// 現在のロケールの記事
'suppress_filters' => false,
'lang' => $locale,
// 全件取得
'numberposts' => '-1',
'orderby' => 'ASC',
'tag' => $value->slug
);
$posts = get_posts( $arg_tag );
global $post;
?>
<ul>
<?php foreach( $posts as $post ): ?>
<li><?php the_time( 'Y.m.d' ); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<?php
endforeach;
$wp_query = $original_query;
wp_reset_postdata();
?>
</div>