Skip to content

Instantly share code, notes, and snippets.

@kmdsbng
Created October 12, 2021 06:15
Show Gist options
  • Save kmdsbng/3ce8a5c252254deabc6ea023095d516d to your computer and use it in GitHub Desktop.
Save kmdsbng/3ce8a5c252254deabc6ea023095d516d to your computer and use it in GitHub Desktop.
タクソノミーリストを表示して一覧を表示する
<?php
/**
* The template for displaying archive pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage Twenty_Nineteen
* @since Twenty Nineteen 1.0
*/
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php if ( have_posts() ) : ?>
<?php $taxonomies = get_taxonomies(); ?>
<header class="page-header">
<?php
the_archive_title( '<h1 class="page-title">', '</h1>' );
?>
</header><!-- .page-header -->
<?php while ( have_posts() ) : the_post(); ?>
<?php foreach ( $taxonomies as $taxonomy ) { ?>
<?php
$term = get_the_terms($post->ID,$taxonomy);
if ($term[0]) {
?>
<div style="margin: 0 10%">
<?php
$taxobj = get_taxonomy($taxonomy);
echo $taxobj->label . " : " . $term[0]->name;
?>
</div>
<?php
}
?>
<?php } ?>
<?php
get_template_part( 'template-parts/content/content', 'excerpt' );
?>
<?php endwhile; ?>
<?php
// Previous/next page navigation.
twentynineteen_the_posts_navigation();
// If no content, include the "No posts found" template.
else :
get_template_part( 'template-parts/content/content', 'none' );
endif;
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment