Skip to content

Instantly share code, notes, and snippets.

@867
Last active December 10, 2023 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 867/2e0533f689eee7b208cef3e0f889500b to your computer and use it in GitHub Desktop.
Save 867/2e0533f689eee7b208cef3e0f889500b to your computer and use it in GitHub Desktop.
Snow-Monkey:カスタム投稿タイプのタクソノミーターム一覧をアクションフック内に表示する
<?php
/**
* アーカイブページのエントリーコンテンツの後にカスタム投稿タイプのタクソノミーターム一覧を出力する
*/
add_action(
'snow_monkey_after_archive_entry_content',
function() {
$post_type = get_post_type();
$args = array(
'taxonomy' => 'blog-cat',
'hide_empty' => true,
);
if( 'blog' === $post_type ) {
$terms = get_terms( $args );
if( $terms && !is_wp_error( $terms ) ) {
echo '<ul class="">'."\n";
echo walk_category_tree( $terms, 0, array(
'use_desc_for_title' => false,
'style' => 'list',
));
echo '</ul>'."\n";
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment